0

I have used "RichTextArea" in GWT. Now i want to trim the text of the richtextarea.gettext() when i am submitting the form.

But if i have only entered spaces and enter key in my textarea then richtextarea.gettext() will not going to trim it as it will convert them to &nbsp and < br>.

Any suggestion if there are only entered spaces and enter key in my textarea then on trim it should give me blank string value?

Sumit Prajapati
  • 91
  • 1
  • 12

1 Answers1

1

That you get &nbsp and < br> is the correct value what you get from the RichTextArea because it supplies HTML.

Implement your own trim-method:

public String trim(String s) {

   String result = s.trim(); 
   String x = result.replaceAll("<br>", "");
   x = x.replaceAll("&nbsp", "");
   x = x.trim();
   if(x.equals("")) {
       return x;
   } else {
       return result;
   }
}
Sam
  • 2,707
  • 1
  • 23
  • 32