This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 124876 - Viewing a table with string containing <HTML></HTML> tags.
Summary: Viewing a table with string containing <HTML></HTML> tags.
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: Macintosh All
: P3 blocker (vote)
Assignee: David Vancouvering
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-08 11:30 UTC by crosati
Modified: 2008-08-20 17:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description crosati 2008-01-08 11:30:58 UTC
When viewing data of a table containing strings values in the following format

  <HTML>...</HTML>

will display the string formatting it in HTML. If no other HTML tags exists (<B>, <I>, ect.) the string is written in a way that makes it impossible to distinguish 
from a non-HTML string, thus letting the user think that the string is wrong (i.e. without the initial and final HTML tags).

I suggest the renderer should use an icon to show the string is HTML-formatted (or/and use another color - i.e. blue - for HTML-formatted text).

Claudio
Comment 1 David Vancouvering 2008-01-08 18:41:22 UTC
Hi.  Where are you viewing this table.  In the SQL Query editor, or in an HTML page/table?  Is this when
designing/running a web application?
Comment 2 crosati 2008-01-08 20:44:49 UTC
In the SQL Editor, after opening a connection with the DB.
It was during the development of a stand-alone application.
Comment 3 David Vancouvering 2008-01-08 21:00:46 UTC
OK.  I'm going to change this to an enhancement request.  Let me know if you disagree.
Comment 4 crosati 2008-01-08 22:27:56 UTC
Today I have spent an hour before to understand that the data I wrote in the table was correct and that just its representation in NetBeans was wrong.
And this only after having downloaded DBVisualizer and having discovered the data was right with it.

I'm not sure it is an enhancement. I think is a bug, maybe of not high priority, but is a bug.

What I think is that DB data must be visualized as is. Only under user request (a menu choice or a button pressed) it could be "rendered" somehow else.

Claudio
Comment 5 David Vancouvering 2008-01-08 23:03:50 UTC
OK, good argument.  Pain in the b**t, I can see that, and it is definitely arguable whether it's an enhancement or a
defect, so in the spirit of The Customer is Always Right let's make it a defect.

If I understand you correctly, you're saying that NetBeans Query Editor should not be in the business of trying to
render HTML, it should just print the data as it sees it, or at least have an option to do that.

Let me know if I got that wrong, otherwise I'll assume that's the goal.  
Comment 6 crosati 2008-01-09 07:47:37 UTC
You are right. This is the goal.

Moreover, being that any string starting with <HTML> and ending with </HTML> is automatically rendered in HTML by JLabel (or DefaultTableCellRenderer, that I think you're using), I think that if you are using a DefaultTableCellRenderer (or a sub-class) it should be enough call putClientProperty("html", null) to solve the problem, as in the following example.

Claudio



package test.swing;

import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class HTMLinJLabelsTest 
{

    public static void main ( String[] args ) 
	{
		
		JFrame	frame = new JFrame("HTML in JLabels Test");
		JLabel	l1    = new JLabel("<HTML>HTML <B>rendered</B> <I>label</I>.</HTML>", JLabel.CENTER);
		JLabel	l2    = new JLabel("<HTML>No HTML <B>rendered</B> <I>label</I>.</HTML>", JLabel.CENTER);
		
		l2.putClientProperty("html", null);
		
		frame.setLayout(new BorderLayout());
		
		frame.add(l1, BorderLayout.NORTH);
		frame.add(l2, BorderLayout.SOUTH);
		
		frame.pack();
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationByPlatform(true);
		frame.setVisible(true);
		
    }

}

Comment 7 David Vancouvering 2008-01-09 17:40:06 UTC
Now that *is* helpful, thank you!  I think the place to do this in the constructor for SQLResultPanel at
db/core/src/org/netbeans/modules/db/sql/execute/ui/SQLResultPanel.java.  If I understand correctly what you are saying,
you should be able to disable the "html" property on the whole panel.
Comment 8 crosati 2008-01-10 08:38:40 UTC
If you are using a single TableCellRenderer for the whole table (and not one for each column) it is enough disable the "html" just for the renderer 
component before to assign it to the table:

  TableCellRenderer tcr = ...;

  tcr.putClientProperty("html", null);
  table. setDefaultRenderer(Object.class, tcr);

and what I think important is that should be the DEFAULT behaviour. Only AFTER seeing that a cell (or a column) contains HTML tagged strings (i.e. raw 
data) the user could have the possibility to choose a different rendering of the data (i.e. HTML one).

Ciao, Claudio
Comment 9 David Vancouvering 2008-01-28 23:46:50 UTC
Fixed, revision 6d035eaa25c3

See http://hg.netbeans.org/main?cmd=changeset;node=6d035eaa25c3
Comment 10 David Vancouvering 2008-01-28 23:47:12 UTC
Fixed
Comment 11 Quality Engineering 2008-08-20 17:23:46 UTC
Integrated into 'main-golden', available in build *200808201401* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/a06cac2b5666
User: ahimanikya@netbeans.org
Log: Ensure we don't regress for #124876, disable HTML