engram
1 Sep 2010, 6:17 AM
Hi,
is there any support by the GXT framework for parsing an upload response. We are using a FormPanel like this:
formPanel.setAction(GWT.getModuleBaseURL() + "MyServlet");
formPanel.setEncoding(Encoding.MULTIPART);
formPanel.setMethod(Method.POST);
formPanel.addListener(Events.Submit, new Listener<FormEvent>() {
@Override
public void handleEvent(final FormEvent event) {
System.out.println(event.getResultHtml());
}
}
The result from the server (event.getResultHtml()) is, as the name implies, is HTML encoded although we write plain text at the server:
response.setContentType("text/plain");
final PrintWriter out;
try {
out = response.getWriter();
if (!success) {
out.println("success");
} else {
out.println("failure");
}
}
In this example the response would be "<PRE>success</PRE>" respectively "<PRE>failure</PRE>", but not "success" or "failure".
The problem is that more complex responses would lead to quite complex "html documents" that are error-prone to parse. Moreover different browser will generate different html responses so that it is nearly impossible to parse them in general.
Are there any best practices for this problem or are we doing anything wrong?
Regards,
engram
is there any support by the GXT framework for parsing an upload response. We are using a FormPanel like this:
formPanel.setAction(GWT.getModuleBaseURL() + "MyServlet");
formPanel.setEncoding(Encoding.MULTIPART);
formPanel.setMethod(Method.POST);
formPanel.addListener(Events.Submit, new Listener<FormEvent>() {
@Override
public void handleEvent(final FormEvent event) {
System.out.println(event.getResultHtml());
}
}
The result from the server (event.getResultHtml()) is, as the name implies, is HTML encoded although we write plain text at the server:
response.setContentType("text/plain");
final PrintWriter out;
try {
out = response.getWriter();
if (!success) {
out.println("success");
} else {
out.println("failure");
}
}
In this example the response would be "<PRE>success</PRE>" respectively "<PRE>failure</PRE>", but not "success" or "failure".
The problem is that more complex responses would lead to quite complex "html documents" that are error-prone to parse. Moreover different browser will generate different html responses so that it is nearly impossible to parse them in general.
Are there any best practices for this problem or are we doing anything wrong?
Regards,
engram