Question

I have a com.google.gwt.user.client.ui.RichTextArea with text "Hello World". When I do:

IE / CHROME

String text = richTextArea.getText(); // I get "Hello World" - CORRECT
String value = richTextArea.getHTML();  // I get "Hello World" - CORRECT

FIREFOX

String text = richTextArea.getText(); // I get "Hello World" - CORRECT
String value = richTextArea.getHTML();  // I get "Hello World<br>" - INCORRECT

Any Ideas?

THANK YOU!

Was it helpful?

Solution

The GWT issue logged for this - http://code.google.com/p/google-web-toolkit/issues/detail?id=6798

Work Around - Sanitize the html string -

Class MyRichTextArea extends RichTextArea{
       public String getHTML() {
        return super.getHTML().equals("<br>") ? "" : super.getHTML();
    }
}

This is not exactly a GWT specific bug.

OTHER TIPS

I have read that this issue has been already reported as a bug. Meanwhile, we can get around this with a code like this:

String value = richTextArea.getHTML();
if(value.lastIndexOf("<br>") == value.length()-4)
  value = value.substring(0, value.length()-4);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top