Tuesday, November 29, 2011

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

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

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment