Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem using editorType="custom.Class" in ds.xml

    SmartClient Version: SC_SNAPSHOT-2011-08-02/PowerEdition Deployment (built 2011-08-02)

    I'm trying to implement a custom editor for a field. I created a subclass of IPickTreeItem shown below. But when I attach it to my field by putting editorType="com.islandpacific.gui.client.IpClassPicker" in the ds.xml I get a javascript error shown below when I try to create a form with that field on it.

    The dev console shows this.
    Code:
    08:02:52.510:MUP5:WARN:DynamicForm:isc_DynamicForm_6:Problem initializing item: {__ref: {GWT Java Obj},
    name: "itemClass",
    itemHoverHTML: anonymous(),
    wrap: false,
    titleDoubleClick: anonymous(),
    detail: true,
    editorType: "com.islandpacific.gui.client.IpClassPick..."[42],
    nativeName: "ICLS",
    primaryKey: true,
    title: "Class",
    type: "integer",
    validators: Array[1]} - derived FormItem class is: com.islandpacific.gui.client.IpClassPicker.  Please make sure the relevant module is loaded
    Javascript error
    Code:
    Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): _4[i] is undefined
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.smartgwt.client.widgets.form.DynamicForm.create(DynamicForm.java)
        at com.smartgwt.client.widgets.BaseWidget.getOrCreateJsObj(BaseWidget.java:361)
        at com.smartgwt.client.widgets.tab.Tab.setPane(Tab.java:603)
        at com.islandpacific.gui.client.IpTabbedForm.<init>(IpTabbedForm.java:221)
        at com.islandpacific.gui.client.GenericEditor.<init>(GenericEditor.java:64)
        at com.islandpacific.gui.client.ConstantsDefinition.getEditTab(ConstantsDefinition.java:168)
        at com.islandpacific.gui.client.ConstantsDefinition.handleMenuSelection(ConstantsDefinition.java:116)
        at com.islandpacific.gui.client.ConstantsDefinition$2.onClick(ConstantsDefinition.java:108)
        at com.smartgwt.client.widgets.menu.events.MenuItemClickEvent.dispatch(MenuItemClickEvent.java:98)
        at com.smartgwt.client.widgets.menu.events.MenuItemClickEvent.dispatch(MenuItemClickEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:193)
        at com.google.web.bindery.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:88)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:127)
        at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:248)
        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.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
        at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
        at java.lang.Thread.run(Thread.java:680)
    Here is the class.
    Code:
    package com.islandpacific.gui.client;
    
    import com.islandpacific.gui.clientServer.dsConstants.Item;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.widgets.form.fields.IPickTreeItem;
    
    public class IpClassPicker extends IPickTreeItem{
    
    	public IpClassPicker() {
    		super();
    		DataSource merchHierarchyDS = DataSource.get(IslandPacificDSConstants.DATASOURCE_IPMerchHierarchyDS);
    		setDataSource(merchHierarchyDS);
    		setValueField("Code");
    		setCanSelectParentItems(false);
    	}
    }

    #2
    You need to use DataSourceField.setEditorType(FormItem) to provide a custom FormItem. GWT does not support reflection, so a fully qualified className does not give us a way to obtain an instance of your FormItem.

    Comment


      #3
      Does that mean I can't just put editorType="myClass" in the ds.xml? Where would I put the call to DataSourceField.setEditorType() so that it is applied globally?

      Comment


        #4
        No, it means an editorType attribute in a .ds.xml file cannot in general be used to refer to a custom Java class you have built in GWT, because GWT does not support reflection.

        Not sure what you mean by "globally", but if you load the DataSource, grab the field and call setEditorType(), that's all you need to do.

        Comment

        Working...
        X