Get RAW text with LineBreak in the text from contenteditable field in GWT?

43 Views Asked by At

I try do my note-book in GWT We have a field whose content is stored in the database. How to transfer to the server user text with a linebreaks? I use Document.get().getElementById("note_01").getInnerText() - it returns the text on single-line. write:

1

2

3

got: 123, but need RAW text copy with linebreaks....

1

2

3

or how to fill in this contenteditable field so it got a raw text?


upd: okay google. I found solution: in this case just need use .getInnerHTML() and replace tags to \n on server-side. Thanks for all!

1

There are 1 best solutions below

1
mxlse On BEST ANSWER

.getInnerText() gives you just the text while .getInnerHTML() would include the HTML markup. If you use <br>-tags perhaps you have to replace them with \n, depending on your further usage of the text or the way you want to store it in the DB.

Is there a reason you are using GWT 2.5 (if you are starting the project from scratch - what it sounds like)?