Announcement

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

    Problems setting Datasource in Component XML

    I am trying to define my own ListGrid using a custom constructor like this (similar to the customComponent example in the EEShowcase):

    CustomListGrid.ui.xml
    Code:
    <ListGrid xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        constructor="com.aCompany.client.CustomListGrid"
        ID="CustomListGrid" autoDraw="false" dataSource="SomeBean" autoFetchData="true"
        width="600" height="400">
    </ListGrid>
    SomeBean.ds.xml
    Code:
    <DataSource 
    	beanClassName="com.aCompany.SomeBean"
    	ID="SomeBean"
    	serverType="hibernate"
    	autoDeriveSchema="false"
        dropExtraFields="true"
    >
    	<fields>
    		<field primaryKey="true" name="id" type="sequence"></field>
    		<field name="anotherBeanId" type="integer"></field>
    		<field name="aProperty" type="text"></field>
    		<field name="anotherBean" title="AnotherBean" canEdit="false" foreignKey="AnotherBean.id" multiple="true">
                <displayField>anotherProperty</displayField>
                <filterEditorType>SelectItem</filterEditorType>
                <optionDataSource>AnotherBean</optionDataSource>
                <valueField>id</valueField>
            </field>
    	</fields>
    </DataSource>
    This works, as long as dataSource="SomeBean" autoFetchData="true" are ommited in above customComponent definition for the CustomListGrid and the respective properties are set programmatically like this
    Code:
    RPCManager.loadScreen("CustomListGrid", new LoadScreenCallback() {			
    	@Override
    	public void execute() {
    		final DynamicForm dynamicForm = (DynamicForm) Canvas.getById("ViewsForm");
    		final ListGrid filmGrid = (ListGrid)Canvas.getById("CustomListGrid");
    		
    		DataSource filmDS = DataSource.get("SomeBean");
    		filmGrid.setDataSource(filmDS);
    Otherwise (if set directly in the CustomListGrid's component XML), the following exception is raised:
    Code:
    java.lang.IllegalArgumentException: Could not set property com.aCompany.client.CustomListGrid.dataSource given value of type java.lang.String
        at com.smartgwt.client.bean.BeanProperty.setProperty(BeanProperty.java:77)
        at com.smartgwt.client.bean.BeanFactory.doSetProperty(BeanFactory.java:963)
        at com.smartgwt.client.bean.BeanFactory.doSetProperty(BeanFactory.java:958)
        at com.smartgwt.client.bean.BeanFactory.setProperty(BeanFactory.java:715)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        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:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
        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:242)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        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: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(Thread.java:722)
    Caused by: java.lang.IllegalArgumentException: Could not convert from java.lang.String to com.smartgwt.client.data.DataSource
        at com.smartgwt.client.bean.BeanValueType.conversionException(BeanValueType.java:601)
        at com.smartgwt.client.bean.BeanValueType.convertFrom(BeanValueType.java:595)
        at com.smartgwt.client.bean.types.JsoWrapperValueType.convertFrom(JsoWrapperValueType.java:109)
        at com.smartgwt.client.bean.BeanMethod.setProperty(BeanMethod.java:83)
        at com.smartgwt.client.bean.BeanProperty.setProperty(BeanProperty.java:72)
        at com.smartgwt.client.bean.BeanFactory.doSetProperty(BeanFactory.java:963)
        at com.smartgwt.client.bean.BeanFactory.doSetProperty(BeanFactory.java:958)
        at com.smartgwt.client.bean.BeanFactory.setProperty(BeanFactory.java:715)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        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:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
        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:242)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        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: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(Thread.java:722)
    What could be the problem here?

    SmartClient Version: SNAPSHOT_v9.0d_2013-05-09/EVAL Deployment

    Thanks,
    fatzopilot

    #2
    Thanks for pointing this out.

    What you were doing should now work in the latest nightly builds -- if you get a chance to check it out, let us know if you run into any problems.

    Comment

    Working...
    X