Hi,
I can't get the following example to work. Basically I want to create SimpleType for displaying AND EDITING numbers according to local format. There is no problem with displaying thanks to SimpleType.setNormalDisplayFormatter(), but am not able to get the same format while editing (both grid and form).
I can create FormItem with setEditorValueFormatter() and setEditorValueParser() and then use ListGrid.setEditorType() and DynamicForm.setEditorType() which works, but according to the docs I should be able to use SimpleType.setEditorType() instead.
Unfortunately I got an error here:
amountType.setEditorType(new FloatItem());
00:07:12,486 [ERROR] Unable to load module entry point class org.yournamehere.client.MainEntryPoint (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (TypeError): className.startsWith is not a function fileName: http://localhost:8080/TestSimpleType/sc/client/widgets/form/FormItemFactory.js lineNumber: 78 stack: ([object Object])@http://localhost:8080/TestSimpleType/sc/client/widgets/form/FormItemFactory.js:78 ([object Object],[object Object])@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1704 ([object Array],null,true,true)@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1594 ([object Array],true)@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1430 ([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1290 ([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://localhost:8080/TestSimpleType/sc/client/widgets/Canvas.js:2581 ([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://localhost:8080/TestSimpleType/sc/client/language/Class.js:1627 ([object Object])@http://localhost:8080/TestSimpleType/sc/client/language/Class.js:135 ()@http://localhost:8080:450 @:0 ([object GWTJavaObject],2556055)@http://localhost:8080/TestSimpleType/hosted.html?org_yournamehere_Main:56 ()@http://localhost:8080:290 connect("http://localhost:8080/TestSimpleType/?gwt.codesvr=127.0.0.1:9997","Ojn)`ssFd/?))vd~","127.0.0.1:9997","org.yournamehere.Main","2.0")@:0 ((void 0),"org.yournamehere.Main","http://localhost:8080/TestSimpleType/")@http://localhost:8080/TestSimpleType/hosted.html?org_yournamehere_Main:264 z()@http://localhost:8080/TestSimpleType/org.yournamehere.Main.nocache.js:2 (-6)@http://localhost:8080/TestSimpleType/org.yournamehere.Main.nocache.js:11 at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at com.smartgwt.client.widgets.form.DynamicForm.fetchData(DynamicForm.java) at org.yournamehere.client.MainEntryPoint.onModuleLoad(MainEntryPoint.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:619)
Thanks for help.
MichalG
ps SmartGWT svn 1116, GWT2
I can't get the following example to work. Basically I want to create SimpleType for displaying AND EDITING numbers according to local format. There is no problem with displaying thanks to SimpleType.setNormalDisplayFormatter(), but am not able to get the same format while editing (both grid and form).
I can create FormItem with setEditorValueFormatter() and setEditorValueParser() and then use ListGrid.setEditorType() and DynamicForm.setEditorType() which works, but according to the docs I should be able to use SimpleType.setEditorType() instead.
Unfortunately I got an error here:
amountType.setEditorType(new FloatItem());
Code:
package org.yournamehere.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.core.DataClass; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.SimpleType; import com.smartgwt.client.data.SimpleTypeFormatter; import com.smartgwt.client.data.fields.DataSourceIntegerField; import com.smartgwt.client.types.DSDataFormat; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.widgets.DataBoundComponent; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FloatItem; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.layout.VLayout; public class MainEntryPoint implements EntryPoint { public MainEntryPoint() { } public void onModuleLoad() { final NumberFormat amountFormat = NumberFormat.getFormat("###,###.###"); SimpleType amountType = new SimpleType("amount", FieldType.FLOAT); amountType.setNormalDisplayFormatter(new SimpleTypeFormatter() { @Override public String format(Object value, DataClass field, DataBoundComponent component, Record record) { return amountFormat.format(Double.valueOf(value.toString())); } }); amountType.setShortDisplayFormatter(new SimpleTypeFormatter() { public String format(Object value, DataClass field, DataBoundComponent component, Record record) { return amountFormat.format(Double.valueOf(value.toString())); } }); amountType.setEditorType(new FloatItem()); //error amountType.register(); DataSource ds = new DataSource(); ds.setDataFormat(DSDataFormat.XML); ds.setRecordXPath("/List/country"); ds.setDataURL("data.xml"); DataSourceIntegerField pkField = new DataSourceIntegerField("pk"); pkField.setHidden(true); pkField.setPrimaryKey(true); DataSourceField areaField = new DataSourceField(); areaField.setName("area"); areaField.setType(amountType); ds.setFields(pkField, areaField); ListGrid grid = new ListGrid(); grid.setWidth(300); grid.setCanEdit(true); grid.setDataSource(ds); grid.filterData(); grid.setDataSource(ds); grid.filterData(); final DynamicForm form = new DynamicForm(); form.setDataSource(ds); form.fetchData(); VLayout main = new VLayout(); main.addMember(grid); main.addMember(form); main.draw(); } }
com.google.gwt.core.client.JavaScriptException: (TypeError): className.startsWith is not a function fileName: http://localhost:8080/TestSimpleType/sc/client/widgets/form/FormItemFactory.js lineNumber: 78 stack: ([object Object])@http://localhost:8080/TestSimpleType/sc/client/widgets/form/FormItemFactory.js:78 ([object Object],[object Object])@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1704 ([object Array],null,true,true)@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1594 ([object Array],true)@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1430 ([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://localhost:8080/TestSimpleType/sc/client/widgets/form/DynamicForm.js:1290 ([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://localhost:8080/TestSimpleType/sc/client/widgets/Canvas.js:2581 ([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://localhost:8080/TestSimpleType/sc/client/language/Class.js:1627 ([object Object])@http://localhost:8080/TestSimpleType/sc/client/language/Class.js:135 ()@http://localhost:8080:450 @:0 ([object GWTJavaObject],2556055)@http://localhost:8080/TestSimpleType/hosted.html?org_yournamehere_Main:56 ()@http://localhost:8080:290 connect("http://localhost:8080/TestSimpleType/?gwt.codesvr=127.0.0.1:9997","Ojn)`ssFd/?))vd~","127.0.0.1:9997","org.yournamehere.Main","2.0")@:0 ((void 0),"org.yournamehere.Main","http://localhost:8080/TestSimpleType/")@http://localhost:8080/TestSimpleType/hosted.html?org_yournamehere_Main:264 z()@http://localhost:8080/TestSimpleType/org.yournamehere.Main.nocache.js:2 (-6)@http://localhost:8080/TestSimpleType/org.yournamehere.Main.nocache.js:11 at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) at com.smartgwt.client.widgets.form.DynamicForm.fetchData(DynamicForm.java) at org.yournamehere.client.MainEntryPoint.onModuleLoad(MainEntryPoint.java:74) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222) at java.lang.Thread.run(Thread.java:619)
Thanks for help.
MichalG
ps SmartGWT svn 1116, GWT2
Comment