Saturday, March 29, 2014

Re: How to make a very long non-stop string (without any space in it) break into many new lines when showing in HTMLPanel?

i found the answer:

.messageDisplay{
 word
-wrap:break-word;
}


On Sunday, March 30, 2014 12:16:16 AM UTC+11, Tom wrote:

I have an HTMLPanel inside a FlowPanel which is inside a ScrollPanel like this.

<g:ScrollPanel>       <g:FlowPanel>          <g:HTMLPanel ui:field="showMessageHTMLPanel" width="600px"/>      </g:FlowPanel>  </g:ScrollPanel>  

The showMessageHTMLPanel is used to hold the text that user enter a TextArea.

I want that the showMessageHTMLPanel should show exactly like how it was displayed in TextArea.

Ex,if user types in many sentences in new lines in TextArea, then the showMessageHTMLPanel should show similar like this:

This is text1    This is text2.  

So here is what I did. I uses new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml().

HTML showMessageHTML = new HTML(new SafeHtmlBuilder().appendEscapedLines(message).toSafeHtml());  getView().getShowMessageHTMLPanel().add(showMessageHTML);  

The result is that It breaks the lines quite OK, no problem.

However, When I type a non-stop very long string ( a String that doesn't have any space on it) into a TextArea. Ex, see this non-stop string:

"Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."

As you saw, even this non-stop string has no space, but when typing in TextArea then the string will automatically fall into new lines.

Ok, now when I show that non-stop string in getView().getShowMessageHTMLPanel(), it showed the text as one straight line without any line break:

Aaaaaaaaaaaaaaaaaaaa......aaaaa.  

The user has to scroll the scrollbar to see the complete text. This is unacceptable since it is too hard to see the whole line. Also many urls are non-stop string without spaces. So the user may not be able to copy the url.

How to make a very long non-stop string (without any space in it) break into many new lines when showing in HTMLPanel?

Or

Do you know any other widget that can handle this?

(http://stackoverflow.com/questions/22731546/how-to-make-a-very-long-non-stop-string-without-any-space-in-it-break-into-man)

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment