Hi, I am from Taiwan. I found that SmartGWT is very awesome. And I am trying to use SmartGWT to build web application.
Because of budget, I use SmartGWT client side and develop server side myself with spring frame.
But I encounter some problem need to help.
Thanks a lot first..
Version-
SmartGWT: 4.0
GWT: 2.5.1
My SmartGWT client side RestDataSource code like this:
And, I try to build a server side with spring framework and response data.
And, the actually josn string is:
However, I get some exception when I response a String[] for FieldType.ENUM.
I guess the response json string "rolesSet":["ROLE04","ROLE03","ROLE05"] not match FieldType.ENUM format.
But, How can I fix the problem? What json format can match ENUM valueMap when response from server side?
Thanks.
Because of budget, I use SmartGWT client side and develop server side myself with spring frame.
But I encounter some problem need to help.
Thanks a lot first..
Version-
SmartGWT: 4.0
GWT: 2.5.1
My SmartGWT client side RestDataSource code like this:
Code:
...
setID(id);
setDataFormat(DSDataFormat.JSON);
setDataProtocol(DSProtocol.POSTPARAMS);
// Role Set
DataSourceField roles = new DataSourceField("rolesSet", FieldType.ENUM, "角色"){{
setCanFilter(false);
setRequired(true);
setEditorType(new SelectItem(){{
setMultiple(true);
setMultipleAppearance(MultipleAppearance.PICKLIST);
setOptionDataSource(RoleSelectDS.getInstance());
setValueField("roleId");
setDisplayField("roleName");
setValidators(new Validator[]{});
}
});
setCanEdit(true);
}};
...
Code:
Map<String, Object> m = new HashMap<String, Object>();
String[] roles = new String[u.getUsr().getRoles().size()];
int i=0;
for(Role r : u.getUsr().getRoles()){
roles[i++] = r.getRoleId();
}
m.put("rolesSet", roles);
...
Code:
{"response":{"endRow":"2","data":[
{"usrId":"ABC123","name":"Sam","active":"true","deptId":"DEPT2","rolesSet":["ROLE04","ROLE05"]},
{"usrId":"XYZ123","name":"James","active":"false","deptId":"DEPT3","rolesSet":["ROLE04","ROLE03","ROLE05"]}],
"totalRows":"2","status":"0","startRow":"0"}}
Code:
com.smartgwt.client.core.JsObject$SGWT_WARN: 09:52:06.303:XRP9:WARN:validation:isOneOf validator specified with no specified list of options or valueMap - validator will always fail. Field definition:{name:
"rolesSet", type: "enum", title: "角色", canFilter: false, required: true, editorType: "SelectItem", editorProperties: Obj, canEdit: true, canExport: true, validOperators: Array[11], validators: Array[2]}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Unknown Source)
But, How can I fix the problem? What json format can match ENUM valueMap when response from server side?
Thanks.