-
2 Feb 2009 9:13 PM #1
FormPanel submit response as json format
FormPanel submit response as json format
I am using GWT+GXT and JSon format.
I am submitting the FormPanel and i want to get the response from server as json format.
I added a listener to the formpanel but the FormEvent.resultHtml is coming as null.
When i see it in firebug, the response is shown as :
{"message":"Diagnosis Successfully created","success":true}
How to get this string in FormEvent resultHtml field ?
Code Snippet:
form.addListener(Events.Submit, new Listener<FormEvent>() {
public void handleEvent(FormEvent arg0) {
GWT.log("Result ::"+arg0.resultHtml, null);
}
});
Can anyone help me in solving this problem?
If there is any alternate way to handle this, let me know.
thx.
-
2 Feb 2009 11:12 PM #2
You have to submit to the same domain as the hole page is running, as else you are not able to access the iframe. This is a secrurity restriction in browsers.
-
16 Feb 2009 11:29 AM #3
this works for me !
PHP Code:settingsForm.addListener(Events.Submit, new Listener<FormEvent>() {
public void handleEvent(FormEvent be) {
String response = be.resultHtml;
if(response.indexOf("<pre>") != -1) {
response = response.substring(5, response.length()-6);
}
JSONValue rspValue = JSONParser.parse(response);
JSONObject rspObj = rspValue.isObject();
Window.alert(rspObj.get("message").toString());
}
});


Reply With Quote