I use SmartGWT 3.0p power edition to perform a simple form submit and I use the GWT App Engine for prelim test, and I try the following
- dynamicForm.saveData()
- call client DataSource
- call ds.xml config and call to server through DMI, and
* specify the serverConstructor server endpoint class
* specify the operationBinding and specify the serverObject with POJO
* set serverMethod 'add'
- call Servers' Service with method 'add'
Questions:
1. And as show in the code and I try to print out somethings but I cannot see anythings in the eclipse console view, where can I find the log in server side of GWT App Engine testing?
2. I try to use debug and add a breakpoint onto server side, but I cannot reach the breakpoint, is breakpoint work for GWT App Engine in debug mode?
3. I try to get the response status by 'DSCallback' in client side and get '0', what's the meaning of 0?
4. how can I return the data from server back to client for construction of success message?
Dynamic Form - (Client Side)
Client DataSource - (Client Side)
ds.xml - (Client/Server Side)
Server Side Service Endpoint - (Server Side)
Server Side VO - (Server Side)
- dynamicForm.saveData()
- call client DataSource
- call ds.xml config and call to server through DMI, and
* specify the serverConstructor server endpoint class
* specify the operationBinding and specify the serverObject with POJO
* set serverMethod 'add'
- call Servers' Service with method 'add'
Questions:
1. And as show in the code and I try to print out somethings but I cannot see anythings in the eclipse console view, where can I find the log in server side of GWT App Engine testing?
2. I try to use debug and add a breakpoint onto server side, but I cannot reach the breakpoint, is breakpoint work for GWT App Engine in debug mode?
3. I try to get the response status by 'DSCallback' in client side and get '0', what's the meaning of 0?
4. how can I return the data from server back to client for construction of success message?
Dynamic Form - (Client Side)
Code:
final DynamicForm dynamicForm = new DynamicForm(); dynamicForm.setDataSource(FormSubmitDS.getInstance()); dynamicForm.setAddOperation("add"); final TextItem field1 = new TextItem("field1"); final TextItem field2 = new TextItem("field2"); dynamicForm.setFields(field1 , field2); addMember ( dynamicForm ); IButton submitButton = new IButton("Submit"); submitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub dynamicForm.saveData(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { SC.say ( Integer.toString(response.getStatus()) ); } }); dynamicForm.resetValues(); } }); addMember(submitButton);
Code:
public class FormSubmitDS extends DataSource { private static FormSubmitDS instance = null; public static FormSubmitDS getInstance() { synchronized(FormSubmitDS.class) { if (instance == null) { instance = new FormSubmitDS("FormSubmitData"); } } return instance; } public FormSubmitDS(final String id) { setID(id); setTitleField("FormSubmitData"); final DataSourceTextField field1Field = new DataSourceTextField("field1", "field1"); field1Field.setPrimaryKey(true); field1Field.setRequired(true); final DataSourceTextField field2Field = new DataSourceTextField("field2", "field2"); setFields(field1Field , field2Field); setDataURL("ds/FormSubmitData.ds.xml"); // setClientOnly(true); } }
Code:
<DataSource ID="FormSubmitData" serverConstructor="com.testgwt.server.FormSubmitDataService"> <fields> <field name="field1" type="text" title="field1" required="true"/> <field name="field2" type="text" title="field2"/> </fields> <operationBindings> <binding operationType="add" serverMethod="add" operationId="add"> <serverObject lookupStyle="new" className="com.testgwt.server.data.FormSubmitData" /> </binding> </operationBindings> </DataSource>
Code:
import com.isomorphic.datasource.BasicDataSource; import com.isomorphic.datasource.DSRequest; import com.isomorphic.datasource.DSResponse; import com.testgwt.server.data.FormSubmitData; public class FormSubmitDataService extends BasicDataSource { public DSResponse add(DSRequest dSRequest, FormSubmitData o) throws Exception{ System.out.println("FormSubmitDataService.add"); System.out.println(o.getField1()); System.out.println(o.getField2()); if ( "1".equals(o.getField1()) ) { throw new Exception ("ERROR" ); } return dSRequest.execute(); } }
Code:
package com.testgwt.server.data; public class FormSubmitData { private String field1; private String field2; public String getField1() { return field1; } public void setField1(String field1) { this.field1 = field1; } public String getField2() { return field2; } public void setField2(String field2) { this.field2 = field2; } }
Comment