Line Breaks in Labels Problems

641 views
Skip to first unread message

il1019

unread,
Jun 30, 2009, 4:22:11 PM6/30/09
to Google Web Toolkit
I'm having some issues with line breaks. They work in the Hosted
Browser as well as IE8, however the don't work in Firefox or Opera.
For example, if the user enters code in a text area that has line
breaks (they pressed enter at some point), these line breaks will only
be displayed in IE. I'm wondering if I should just convert the text to
HTML and replace the \n with <br>, however that wouldn't be as clean.
Is this a GWT problem, or am I doing something wrong?

Here is some sample code that shows my problem. If you try anything
with a carriage return, it will work in IE but not in FF or Opera.

VerticalPanel mainPanel = new VerticalPanel();
final Label label = new Label();
final TextArea box = new TextArea();
mainPanel.add(label);
mainPanel.add(box);
Button switchView = new Button("Update Label");
switchView.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
label.setText(box.getText());
}});
mainPanel.add(switchView);
RootPanel.get().add(mainPanel);

For example, if you use the text:

asdf

asdf

asdf

in IE it will render correctly, however anywhere else will simply
show:

asdf asdf asdf

Thanks for your help!

Thomas Broyer

unread,
Jun 30, 2009, 6:15:47 PM6/30/09
to Google Web Toolkit


On 30 juin, 22:22, il1019 <dean.mar...@gmail.com> wrote:
> I'm having some issues with line breaks. They work in the Hosted
> Browser as well as IE8, however the don't work in Firefox or Opera.
> For example, if the user enters code in a text area that has line
> breaks (they pressed enter at some point), these line breaks will only
> be displayed in IE. I'm wondering if I should just convert the text to
> HTML and replace the \n with <br>, however that wouldn't be as clean.
> Is this a GWT problem, or am I doing something wrong?

See issues 314 and 960 (and there might be others)
http://code.google.com/p/google-web-toolkit/issues/detail?id=314
http://code.google.com/p/google-web-toolkit/issues/detail?id=960

Reply all
Reply to author
Forward
0 new messages