Displaying HTML character entities in JEditorPane

Hi,
I have noticed that when displaying HTML character entity references in a JEditorPane it will show some of them, e.g. © for copyright symbol but not others e.g. ’ for "curly" single quote.
Is there any way to get JEditorPane to show all (most?) of them?

Create a class that extends ComboBox and override the
updateDisplayList and measureText functions. Then use that new
ComboBox in your code:
<local:HtmlComboBox .. xmlns:local="components.*".>
<local:itemRenderer>
<mx:Component>
<mx:Text htmlText="{data.label}" />
</mx:Component>
</local:itemRenderer>
</local:HtmlComboBox>
Put this into a folder called "components" and name the file
HtmlComboBox.as
package components
import mx.controls.ComboBox;
import flash.text.TextLineMetrics;
public class HtmlComboBox extends ComboBox
public function HtmlComboBox()
super();
override protected function
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
super.updateDisplayList(unscaledWidth,unscaledHeight);
var s:String = textInput.text;
textInput.htmlText = s;
override public function
measureText(text:String):TextLineMetrics
return measureHTMLText(text);
}

Similar Messages

  • Displaying Numeric Character Entities

    I�m having a problem displaying numeric character entities such as ��� (m-dash) in my Java application. I have noticed that some characters will show up correctly and some will not, for example �}� (Right curly brace) shows up just fine. I�m having the same problem with Japanese numeric character entities such as �&#24335;�. The encoding that is being used here is UTF-8.
    I am reading the text that contains these entities from a XML file using the following code:
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setIgnoringComments(true);
        dbf.setIgnoringElementContentWhitespace(true);
        try {
          FileInputStream fff = new FileInputStream(theFile);
          InputSource inSource = new InputSource(new InputStreamReader(fff,"UTF-8"));
          DocumentBuilder db = dbf.newDocumentBuilder();
          Document doc = db.parse(inSource);
        } catch (Exception e) {
          System.out.println("Exception: " + e);
        }Here is a simple example of an xml file.
    <?xml version="1.0" encoding="UTF-8"?>
    <toc name="Course One" file="course1/toc.xml">
    <topic name="Topic � One" file="course1/source/topic1.html"/>
    <topic name="&#24335; (Japanese char)" file="course1/source/topic2.html"/>
    </toc>When I print out the contents of the name attribute I get boxes (or a ?) in place of the character entity. Any help that can be offered here would be greatly appreciated.
    Thanks,
    David

    I just realized that the entities that I put in my post were resolved by the browser, so they didn't show up as the actual numeric entity code as I intended, &#151; (& + #151;) for m-dash &#125; (& + #125;) for the curly brace and &#24335; (& + #24335;) for the Japanese character. The XML file looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <toc name="Course One" file="course1/toc.xml">
    <topic name="Topic &#151; One" file="course1/source/topic1.html"/>
    <topic name="&#24335; (Japanese char)" file="course1/source/topic2.html"/>
    </toc>

  • Rendering text that contains old-style HTML character entities, e.g. ü

    The large text-corpus I'm working with was produced before the days of widespread Unicode support, and it contains HTML character entities instead of unicode codepoints, e.g. &uuml; for ü [u-umlaut].
    I can iterate through every text column in the ArrayCollections that I'm using for dataProviders to the DataGrid, and replace these entities with their unicode counterparts before the provider is assigned to the grid. But is there already a mechanism in place in Flex to render character entities in the DataGrid? Is there a ready-made ItemRenderer that can do this?
    Thanks

    DrClap wrote:
    So your example looks like this?
    <someNode>der fuchs springt &#252;ber den stein</someNode>
    now I feel stupid :-) Yes, that's correct.
    And you're actually getting an EntityReference node in your Document? I find that rather strange, since the documentation for EntityReference says
    Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference.
    Exactly!
    Because what you have there is a character reference. Is there something else in the document, a DTD for example, which might be interfering with that?No, just an ordinary XML header:
    <?xml version="1.0" encoding="UTF-8"?> ...If it helps, I can also post the complete document I am receiving.

  • Weblogic xss vulnerablity : html character entities getting decoded in jsp by ${} expression

    This is from my question at stack overflow java - Weblogic xss vulnerablity : html character entities getting decoded in jsp - Stack Overflow
    I am using a filter to prevent xss by encoding html character of my jsp form parameters.
    I am resolving them in jsp using ${param} expression.
    This is working fine in tomcat as the values are resolved as is, but on weblogic the values are getting decoded, causing the XSS to succeed
    I am using this simple code in jsp to test it
    <c:set var="testing" value="eb011&quot;&gt;&lt;img src=a onerror=confirm(1)&gt;47379"/> <input type="hidden" name="encoding" value="${testing }"/>
    Result in tomcat
    <input type="hidden" onerror="confirm(1)&gt;47379&quot;/" src="a" &gt;&lt;img="" value="eb011" name="encoding">
    Result in weblogic
    <input type="hidden" value="eb011" name="encoding"><img onerror="confirm(1)" src="a">47379"/&gt;
    why is weblogic decoding html codes and what could be done to prevent it.

    It is really handy to learn how to read schema validation errors. It really does say exactly what's wrong there. If you can get access to the XSD that your XML document is prescribing, you should be able to tell what mistake you made. If you learn how to do this, you'll never have to ask questions like this again. :)
    The error refers to the "http://www.bea.com/ns/weblogic/weblogic-web-app" namespace, which I believe is in your "weblogic.xml" file. It's saying that in the "jsp-descriptor" element, it found a "noTryBlocks" element at a point where it was not legal. At that point, it expected to find either a "'precompile-continue" or several other elements, but not that one. Read the XSD to determine the correct order for elements. If you're editing this file in Eclipse, you may not even have to obtain the XSD. If you hover the mouse over the root element of the document, it will give you a popup showing the syntax details of the element, which will tell you what the expected order of elements is.

  • How do I display Tools Developer Page Source without HTML Character Entities, such as & and

    I am using Firefox 8.0 on Windows XP. In earlier versions of Firefox, when I would display the page source, the page would be displayed in all its original characters, including < > & and so on (including the HTML reserved characters.)
    Now when I display page source, the page source is displayed, but instead of displaying html tags,
    <p> for example,
    it will display &lt;p&gt; in the source instead.
    For a longer example, instead of displaying
    <p class="stuff">text to display</p>
    the source is rendered as
    &lt;p class=&quot;stuff&quot;&gt;text to display&lt;/p&gt;
    Is there a way to direct Firefox to display page source using all actual characters instead of using character entities?

    Clarification.
    The html tags render until it encounters this code:
    <input id="htmlHidden" type="hidden" value="&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;
    &amp;lt;div id=&amp;quot;content-inside&amp;quot;&amp;gt;
    &amp;lt;div id=&amp;quot;content-space&amp;quot;&amp;gt;
    &amp;lt;div id=&amp;quot;about&amp;quot; class=&amp;quot;node&amp;quot;&amp;gt;
    &amp;lt;div class=&amp;quot;node-inner&amp;quot;&amp;gt;...

  • Help -- How to display Html text in a JEditorPane

    I'm trying to display html in a JEditorPane (html is obtained by transforming Xml and Xsl). So after i do the transformation i have a string which is the html source to be displayed. But when i use editorpane.setText(htmlString) method it is displaying the html source in the editorpane. I also tried using the HTMLEditorKit's read method. Even then its displaying the html source. But when i store the html source as a html file and give the editorpane, the url of the html file, it displays properly.
         I would be so grateful if u can help in displaying the html (which i have as a string) instead of the source...
    Thank you so much...

    Hi, after struggling with problem, the solution seems to be to ditch the content type meta tag, JEditorPane seems to barf (silently!) on this...
    So, to turn this off...
    transformer.setOutputProperty(OutputKeys.ENCODING,"");
    Cheers
    Greg

  • Regarding displaying html page in a JEditorPane

    i want to display a html page in a JEditorPane but the problem is it is displying the page but the script part of html page is printed as it is in the pane . please tell the solution for it . i will be highly thankful to u.

    What you are doing exactly? you are displaying the html file into a JEditorPane or After displaying you are tring to Print it out in the Paper or what.
    If this the First Sinario then this code will help you.
    import javax.swing.*;
    import java.awt.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    public class Htmlexample extends JInternalFrame {
         //Constructor of Class.
         public Htmlexample () {
              //super(Title, Resizable, Closable, Maximizable, Iconifiable)
              super (title, true, true, true, true);
              setSize (500, 350);
              HtmlPane html = new HtmlPane ("Help/Keys.htm");     
              setContentPane (html);                    
              setVisible (true);
    //Following Class Show HTML Help inside an EditorPane.
    class HtmlPane extends JScrollPane implements HyperlinkListener {
         JEditorPane html;
         public HtmlPane (String filename) {
              try {
                   File f = new File (filename);          
                   String s = f.getAbsolutePath();          
                   s = "file:" + s;
                   URL url = new URL (s);               
                   html = new JEditorPane (s);          
                   html.setEditable (false);          
                   html.addHyperlinkListener (this);
                   JViewport vp = getViewport();     
                   vp.add (html);                    
              catch (MalformedURLException e) { }
              catch (IOException e) {     }
         //Function Perform By the HyperLinks of HTML Help File.
         public void hyperlinkUpdate (HyperlinkEvent e) {
              if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                   linkActivated (e.getURL());
         //Function for Loading other HTML Pages in Your HTML Help.
         protected void linkActivated (URL u) {
              Cursor c = html.getCursor();
              Cursor waitCursor = Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR);
              html.setCursor (waitCursor);
              SwingUtilities.invokeLater (new PageLoader (u, c));
         //Following Class Load Other Pages Included in Our HTML Help File.
         class PageLoader implements Runnable {
              //Constructor of Class.
              PageLoader (URL u, Cursor c) {
                   url = u;
                   cursor = c;
              public void run () {
                   if (url == null) {
                        html.setCursor (cursor);
                        Container parent = html.getParent();
                        parent.repaint();
                   else {
                        Document doc = html.getDocument();
                        try {
                             html.setPage (url);
                        catch (IOException ioe) {
                             html.setDocument (doc);
                             getToolkit().beep();
                        finally {
                             url = null;
                             SwingUtilities.invokeLater (this);
              URL url;
              Cursor cursor;
    }if there is any other issue Let me Know
    Thank you
    Jofin

  • Assign HTML character entities

    Hello,
    I have a scenario where a message should be sent to an HTTP server using the HTTP receiver CC. In the message itself no special HTML characters such as <, > or / should be used but they should be replaced with special character entities such as &lt for < .
    Is there an easy way to do this as it is quite a common requirement? Is there an adapter module available for this or must this be done in the mapping itself?
    Thank you for your advice.
    Edited by: Florian Guppenberger on Aug 11, 2009 6:54 PM
    Edited by: Florian Guppenberger on Aug 11, 2009 6:55 PM

    > public void execute(InputStream in, OutputStream out)
    >           throws StreamTransformationException {
    > try{   
    > int c;
    >     while ((c = in.read()) != -1) {
    >       switch (c){      
    >          case '&': out.write("&amp ;".getBytes()); break;   
    >          case '&lt;': out.write("&lt ;".getBytes()); break;
    >          case '>': out.write("&gt ;".getBytes()); break;
    >          default: out.write(c);
    >        }
    >
    >     }
    >   } catch (IOException e) {
    >     throw new StreamTransformationException(e.getMessage());
    >   }
    >
    >
    > }
    The SDN forum does not allow html escape sequences, so I put a space before the ; which you have to remove in your code.
    ' and " need not to be escaped, so I removed that lines.
    Edited by: Stefan Grube on Aug 16, 2009 11:06 PM

  • HTML character entities problem in saved regex search and replace query

    I have a many search and replace regular expression queries (.dwr files) that I have saved. I have a problem specifically with saved queries that contain HTML entities such as "& nbsp ; " or "& shy ;" (spaces added otherwise code doesn't render in browser). For example if I use the following search:
    ([\d]{3}& shy ;[\d]{3}& shy ;[\d]{4}|[\d]{3}& nbsp ;[\d]{3}& nbsp ;[\d]{4})
    (which searches for numbers in the 888-555-1234 or 888 555 1234 formats)
    This will work fine if I manually enter it into the search text area. However if I save it to file and reload it, it will no longer work because the &shy; and   characters are now displayed as " " (space) and "-"(shy) rendering the saved query useless as it's no longer searching for the code. I have some fairly long and complex queries and this is becoming a problem.
    Thanks for any help.
    I'm currently using Dreaweaver CS4 at home and CS5.5 at work.

    Thanks for your reply Kenneth, but that is not what I'm trying to accomplish. I'm looking for the HTML entities that exist in the source code which are & shy ; and & nbsp ; (without the spaces). As I mentioned above, if I enter them manually in the search box, I will get the corrrect results. If I save the search and then reload it, the special characters are no longer in HTML and the search is now useless.
    Just for example again
    In an open document in code view insert a number in the format (without the spaces): 888& nbsp;888& nbsp ;8888
    Open a search dialog box and enter (without the spaces): [\d]{3}& nbsp ;[\d]{3}& nbsp ;[\d]{4}
    The search will find that entry.
    Save search as phone.dwr for example. Then load it and try the search again. It won't work because upon loading the search Dreamweaver replaces the HTML code which was saved with the rendered HTML. So now the search shows up as: [\d]{3} [\d]{3} [\d]{4} which will not find the string with hard coded non-breaking spaces that I'm looking for.
    Basically I want to be able to save a search query for reuse. When I load a search query, I want it to be exactly what I saved, not something that DW has rendered (that doesn't work).

  • JEditorPane doesn�t display HTML special char. codes

    My application is using JEditorPane to display text/html.
    The problem comes when I try to display HTML special character codes such as
    &gt; JEditorPane ignores those codes and displays nothing.
    Do I have to convert all those strings representing special characters?
    How could I solve it?
    Thanks in advance,
    Bruno

    Here's my solution - I replace the HTMLEditorKit if it's not the first pass through. I found that the EditorKit is an instance of HTMLEditorKit for every pass except the first (which doesn't have a problem).
    EditorKit ek = displayJEditorPane.getEditorKit();
    if( ek instanceof HTMLEditorKit ) {
         // Needs to be replaced
         HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
         displayJEditorPane.setEditorKit( htmlEditorKit );
    // Display the HTML document
    displayJEditorPane.setPage( resultURL );I'll spread my Duke Dollars around to everyone who offered a suggestion later today if I don't hear of a better solution.
    Thanks.

  • Problem in displaying html page in JEditorPane....

    Hi All,
    i was trying to display a html page in a JEditorPane. i was able to do that when i'm displaying a html page from a local machine.. But when i try to get the page from some website, it giving me
    "exception access denied (java.net.SocketPermission www.java.sun.com resolve)"
    exception. But if i run the same code thru JBuilder, its working. But thru appletviewer or thru IE or Netscape its throwing the error.. Any suggestion or help is highly appreciated....
    Thanks
    Ragu

    Java Applets are very secure, what is good. Java applets are extremely secure
    what is bad. So Applet cannot open TCP connection to any host rather than its
    home host. So you cannot get the resources from any other server (what is common to
    HTTP).
    In JBuilder iit works cause JBuilder is used for development and security in deevelopment
    is not an issue. But it confuses then you see.
    vpanasenko_even

  • Display HTML in JEditorPane

    Hi
    I am trying to display a String containing HTML text on a JEditorPane.
    I have downloaded the HTML from a webpage using sockets, and now I want to display the downloaded page. I have a project in school about sockets.
    This is why I can't use getPage(URL);
    The following is the code I am using:
    String temp = "String with HTML text"
    HTMLEditorKit htmlEdKit = new HTMLEditorKit();
    JEditorPane.setEditorKit(htmlEdKit);
    JEditorPane.setContentType("text/html");
    JEditorPane.setEditorKitForContentType("text/html", htmlEdKit);
    JEditorPane.setContentType("text");
    JEditorPane.setText(temp);
    When I run the code, all that is displaying is the raw HTML code, with all the tags. As I understand it, this is how it should be done.
    What is wrong, would appreciate some help.
    /David Mossberg

    it's not necessary to use socket but if use socket get the inputstream from it.
    in = socket.getinputstream(); //return inputstream from socket
    htmldoc = JEditorPane.getDocument(); //return the htmldoc in JEditorPane
    if(htmldoc.getlength()>0)
    htmldoc.remove(0,htmlDoc.getLength());//if the htmldoc has some content then remove it
    reader = new InputStreamReader(in);//construct a new reader from in
    JEditorPane.getEditorKit.read(reader,htmldoc,0); //read new content into the htmldoc from reader
    Hope the above code helps you.
    joney

  • Display chinese character HTML in iPS3sp3

    Hi there,
    I am using iPS3sp3 and I modified it so that JSP can display chinese character correctly. But somehow I still can not display the chinese character in normal HTML.For instance, I put chinese character in Ldap.properties file but when user go to the Ldap login screen, the chinese can not be displayed correctly. The following is the modification I have done and can anybody please give me some help?
    adding zh_TW in iwtPlatform-availableLocales
    adding zh_TW in iwtPlatform-locale
    adding BIG5 in iwtPlatform-HTMLcharset
    adding ips.locale=en_US,zh_TW,zh_TW.BIG5 in platform.conf file
    Setting, User's Default Locale: zh_TW
    Setting, User's Default HTML charset: BIG5

    Finally, I made it work. The solution is pretty straight forward. All I need to do is to convert these kind of html file to utf8 encoded files and then, it works perfectly. Hope this might be useful for some people.

  • URGENT: JEditorPane (a Java Browser) displaying HTML form

    Hi,
    I am using JEditorPane to display the wb pages but geeting problem as
    I don't get any kind of event when I click on the HTML form SUBMIT button though it does work but didn't allow me to get the URL of the new page that I got after hitting this SUBMIT button..
    I searched the whole net and it seems to me that lot of people got this problem...
    As I need this for my project please HELP me as soon as possible.

    This may be too late for you (hopefully not), but I had the same problem a little while ago and just figured out how to fix it. Basically, you need to examine the Element structure of the html yourself and manually handle the form, as far as I can tell. There are several ways to display a URL in a JEditorPane, but the most straight-forward (JEditorPane.setPage(URL url)) doesn't actually store the Element structure anywhere accessible. Here's the code to load the page:
    JEditorPane contents;
    HTMLEditorKit kit = new HTMLEditorKit();
    HTMLDocument htmlDoc = new HTMLDocument();
    contents.setEditorKit(kit);
    contents.setDocument(htmlDoc);
    URL url = new URL("http://blahblahblah.com");
    contents.read(url.openStream(), htmlDoc);Now that you have the page loaded correctly, you can access to the Elements within. You can use htmlDoc.getDefaultRootElement() to get the root and then iterate recursively through all the child Elements, checking out the Attributes of each. This will look for the submit button and add a listener to it for you:
    private void parseElements(Element elem) {
        AttributeSet atts = elem.getAttributes();
        //If this is the submit button, add a listener:
             Object model = atts.getAttribute(StyleConstants.ModelAttribute);
             Object type = atts.getAttribute(HTML.Attribute.TYPE);
             if ((type != null) && (type.equals("submit"))) {
                 DefaultButtonModel btn = (DefaultButtonModel) model;
                 btn.addActionListener(new ActionListener() {
                     public void actionPerformed(ActionEvent event) {
                         System.out.println("Yay!");
        //Recurse
        for (int i = 0; i < elem.getElementCount(); i++)
             parseElements(elem.getElement(i));
    }Of course, printing out "Yay!" is not really very helpful. When you're parsing through the Elements, check for the attribute StyleContsants.ModelAttribute. If that exists, you can cast it to the correct type of Model (see the documentation for HTMLDocument.HTMLReader.FormAction for information about what types of models to expect from what types of HTML elements) and store it until the "submit" button is pressed. Then all you have to do is get all the data from the models, format it and submit it to the action URL in either a "get" or a "post." The action URL is stored, in Java 1.3, in the HTML.Tag.Form attribute of one of the Elements (I don't remember which one). Getting that attribute returns a SimpleAttributeSet, and you get the HTML.Attribute.Action out of that. In Java 1.4 it's easier to find, you just have to look for the HTML.Attribure.Action attribute in one of the Elements.
    Why isn't this all automatically done for you? I don't know. Good luck.
    -Nathan

  • Display html button on JEditorPane

    hello,
    i'm building an html editor and i managed to display my tags on a JEditorPane, .... the problem is that buttons don't appear at all on the JEditorPane, can anybody help?
    Thanks in advance,
    Bernard

    I tried it, and it was displayed...
    (Be careful, use jdk1.4 (or >1.3)) many bugs were rectifiated.
    ps:When i tried it, i used a JTextPane but i don't think that's the problem.

Maybe you are looking for

  • IPhone not appearing in iTunes after 3.1 update

    Hi everyone....I went to update to the 3.1 OS for my iPhone 3G but during the update it got stuck at the "connect to iTunes". I have uninstalled iTunes and AMD services multiple times. I managed to restore the phone but after the restore it doesn't a

  • HP Pavilion g6 screen backlight flickers

    Hi, my laptop screen backlight goes off, when I rest my hand on the left side of the touchpad. The darkening of the screen can be also reproduced when a small pressure is applied on the case just above the ethernet port or above the headphones port.

  • How can I make the background of the Menu Bar white? I have Windows Vista

    After downloading the latest version of Firefox, the Menu Bar and the one underneath have a dark background that do not permit me to see the words or signs clearly. How can I fix this?

  • Process Chain failing

    We are having a system wide problem and I'm confused on the following.  We started a process chain during the early morning (00:15) and during the first step the system network went down and the app servers and chain are hanging. This first step in t

  • Error in Business partner

    Hi all. We have SRM 5.0 Extended scenario. We create a program to upload contact person without user in this program we use the following function modules: BUPA_NUMBER_GET  (to get the partner guid) BUPA_ADDRESS_READ (to get the addres guid & addres_