Submitting form and getting annoying "<pre>" tags in the response

244 views
Skip to first unread message

laredotornado

unread,
Nov 29, 2011, 12:57:02 PM11/29/11
to Google Web Toolkit
Hi,

I'm using GWT 2.4. I have a form in which I create a submit button
like so

private Button createSaveButton() {
final Button saveButton = new Button("Save");
saveButton.getElement().setAttribute("name",
SaveXmlServlet.SAVE_BUTTON_PARAM_NAME);
saveButton.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
formPanel.submit();
}
});
return saveButton;
} // createSaveButton

I define an onComplete handler for the form like so

formPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
Window.alert(event.getResults());
}
});

The servlet I submit the form to returns results as plain text.

res.setContentType("text/plain");
final PrintWriter out = res.getWriter();
out.print(saveSucceeded);
out.close();

However, when I actually do the alert, it will attach "<pre>" tags to
the output. For example, if the servlet outputs "true", what is
alerted to the user is "<pre>true</pre>". How do I get this only to
output what was written to the response? I could do some string
manipulation to remove the "<pre>" tags, but that seems like I'm not
addressing the core issue.

Thanks, - Dave

Thomas Broyer

unread,
Nov 29, 2011, 6:39:13 PM11/29/11
to google-we...@googlegroups.com
To render text/plain, browsers "convert" it to HTML with <pre> tags. This is why the doc for FormPanel says to use text/html.
Reply all
Reply to author
Forward
0 new messages