Hello
DynamicForm.submit takes a DSCallback which is invoked only if there are no errors in the returned JSON response (ie the 'status' property is 0). If any errors, the Callback doesn't seem to get invoked. Is it intended behavior? How do I get a callback from submit, irrespective of whether status is 0 or negative number?
here's my sample code:
The response from server looks like this:
Any ideas?
DynamicForm.submit takes a DSCallback which is invoked only if there are no errors in the returned JSON response (ie the 'status' property is 0). If any errors, the Callback doesn't seem to get invoked. Is it intended behavior? How do I get a callback from submit, irrespective of whether status is 0 or negative number?
here's my sample code:
Code:
final DynamicForm form = new DynamicForm(); DataSourceTextField dfname = new DataSourceTextField("name"); DataSource ds = new DataSource(); ds.setFields(dfname); ds.setDataURL("/app/test-submit"); ds.setDataProtocol(DSProtocol.POSTMESSAGE); ds.setDataFormat(DSDataFormat.JSON); form.setDataSource(ds); TextItem name = new TextItem("name", "NAME"); form.setFields(name); IButton btn = new IButton("SUBMIT"); btn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { form.submit(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { // breakpoint on following line is hit only if response json has status == 0 Map<String,String> errors = response.getErrors(); } }); } });
Code:
{"response":{"endRow":0,"totalRows":1,"startRow":0, "status":-1, "error":{"f1":"FAKE ERROR"}, "data":[{"id": 100, "beginDate":"2010-03-21T09:12:33"}]}}
Comment