Announcement

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

    SelectItem getValues() problem

    SmartGwt 3.0p 2-16-2012 nightly
    Gwt 2.4
    Firefox 6.0

    I have the following form...

    Code:
    final DynamicForm addUserForm = new DynamicForm();
    		addUserForm.setAutoFocus(true);  
    		addUserForm.setNumCols(4);    
    		addUserForm.setDataSource(manifestDS);  
    		addUserForm.setAddOperation("add_manifest");
    		addUserForm.setUseAllDataSourceFields(false);  
    		addUserForm.setPadding(0);
    		
    		ListGrid pickListProperties = new ListGrid();
    		pickListProperties.setShowFilterEditor(true);
    		
    		ListGridField fName = new ListGridField("FirstName");
    		ListGridField lName = new ListGridField("LastName");
    		ListGridField pos = new ListGridField("Position");
    		ListGridField dob = new ListGridField("DateOfBirth");
    		ListGridField passportExp = new ListGridField("PassportExpiration");
    		
    		final SelectItem employeeName = new SelectItem("EmployeeId");
    		employeeName.setTitle("Choose Employee");
    		employeeName.setMultiple(true);
    		employeeName.setOptionDataSource(employeesDS);
    		employeeName.setValueField("EmployeeId");
    		employeeName.setDisplayField("FirstName");
    		employeeName.setRequired(true);
    		employeeName.setPickListWidth(450);
    		employeeName.setPickListProperties(pickListProperties);
    		employeeName.setPickListFields(fName, lName, pos, dob, passportExp);
    
    		ButtonItem newButton = new ButtonItem("addManifest");
    		newButton.setTitle("Add To Manifest");
    		newButton.setAlign(Alignment.CENTER);
    		newButton.setWidth(150);
    		newButton.addClickHandler(new ClickHandler() {  
    			public void onClick(ClickEvent event) {
    					SC.say("n: " + employeeName.getValues().length);				
    			}
    		});
    
    		addUserForm.setFields(employeeName, newButton);
    When I press the button I get the following error in my console....
    Code:
    22:11:53.796 [ERROR] [testbed] Uncaught exception escaped
    
    com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:129)
        at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:248)
        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:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        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:213)
        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:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.IllegalArgumentException: Something other than a Java object was returned from JSNI method '@com.smartgwt.client.util.JSOHelper::getArrayValue(Lcom/google/gwt/core/client/JavaScriptObject;I)': JS value of type int, expected java.lang.Object
        at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:178)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:271)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.smartgwt.client.util.JSOHelper.getArrayValue(JSOHelper.java)
        at com.smartgwt.client.util.JSOHelper.convertToJavaStringArray(JSOHelper.java:817)
        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:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        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.fields.SelectItem.getValues(SelectItem.java)
        at com.dws.managemymanifest.client.TestBed$1.onClick(TestBed.java:122)
        at com.smartgwt.client.widgets.form.fields.events.ClickEvent.dispatch(ClickEvent.java:96)
        at com.smartgwt.client.widgets.form.fields.events.ClickEvent.dispatch(ClickEvent.java:1)
        at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)
        at com.google.web.bindery.event.shared.EventBus.dispatchEvent(EventBus.java:40)
        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: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:337)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        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:213)
        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:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Thread.java:722)
    Is there something that I am doing wrong. To my understanding if I have SelectItem.setMultiple(true), and I select more than one entry form the dropdown.... I should be able to do SelectItem.getValues() which returns a String [] of the items that were selected.
    Is this correct or am I missing something?
    Last edited by ajmarrer; 16 Feb 2012, 19:19.

    #2
    Just wanted to follow up and see if anyone has any advice on the problem that I am experiencing. Any help would be appreciated. Thanks in advance!

    Comment


      #3
      Can you show me the code in which you're passing values in SelectItem or to DataSource?

      Comment


        #4
        The code that I am using is shown in my initial post. As for the values that are populating the SelectItem is handled directly by DataBinding in the background. Its simply the data that is part of the table from my SQL source.

        This seems like something trivial that should work for me unless I am doing something incorrectly.

        If you feel any other information would be helpful please just ask.
        Thanks again.

        Comment


          #5
          Of what type is the "EmployeeId" property?

          Comment


            #6
            The EmployeeId field of the Employee Datasource is of type "sequence" in my Employees.ds.xml file.

            In the actual SQL Employee table, its an auto-incremented field.

            Comment


              #7
              Isomorphic, any input on this? Have you found this to be working on your end and its simply that I am doing something incorrectly?

              Comment


                #8
                See the FAQ - we can't run your code, and as far as speculating with you, you're reporting a JavaScript error with no stack trace, so there's little we can do.

                Comment


                  #9
                  It looks like it's bringing back an array of int primitives rather than Strings. Does it work if you use a different property as the valueField? That is, can you try setting "FirstName" as both the displayField and the valueField?

                  Comment


                    #10
                    Thanks for the suggestion! That actually began to work.

                    Given this scenario, it definitely seems like a bug.

                    If I have the following code....

                    Code:
                                   final SelectItem employeeName = new SelectItem("EmployeeId");
                    		employeeName.setTitle("Choose Employee");
                    		employeeName.setMultiple(true);
                    		employeeName.setOptionDataSource(employeesDS);
                    		employeeName.setValueField("EmployeeId");
                    		employeeName.setDisplayField("FirstName");
                    		employeeName.setRequired(true);
                    		employeeName.setPickListWidth(450);
                    		employeeName.setPickListProperties(pickListProperties);
                    		employeeName.setPickListFields(fName, lName, pos, dob, passportExp);
                    and performing employeeName.getValues() throws an error.
                    And if I change the "ValueField" as follows...

                    Code:
                                    final SelectItem employeeName = new SelectItem("EmployeeId");
                    		employeeName.setTitle("Choose Employee");
                    		employeeName.setMultiple(true);
                    		employeeName.setOptionDataSource(employeesDS);
                    		employeeName.setValueField("FirstName");
                    		employeeName.setDisplayField("FirstName");
                    		employeeName.setRequired(true);
                    		employeeName.setPickListWidth(450);
                    		employeeName.setPickListProperties(pickListProperties);
                    		employeeName.setPickListFields(fName, lName, pos, dob, passportExp);
                    and the error goes away. It seems to me like to SelectItem object is not taking the toString() value of the integer value that is being passed in from the "EmployeeId".

                    Below is my Employees.ds.xml file...

                    Code:
                    <DataSource ID="Employees" dbName="manifest"
                    	serverType="sql" tableName="employees">
                    	<fields>
                    		<field name="EmployeeId" type="sequence" primaryKey="true" hidden="true" />
                    		<field name="FirstName" title="First Name" type="text" length="64" required="true" />
                    	</fields>
                    </DataSource>
                    Ideally I would like to be able to maintain the "employeeId" as the "ValueField" because I am using this to "INSERT INTO" my sql table.
                    Any advice or workaround is welcome. Thanks again for all the support!

                    Comment


                      #11
                      I'm having the same exact issue. Any suggestions? solutions?

                      Comment


                        #12
                        What is the definition for "manifestDS"?

                        Comment


                          #13
                          manifest.ds.xml file is shown below...

                          Code:
                          <DataSource ID="Manifest" dbName="manifest"	
                          serverType="sql" tableName="manifest">
                          	<fields>
                          		<field name="ManifestId" type="sequence" primaryKey="true" hidden="true" />
                          		<field name="EmployeeId" type="integer" hidden="true" foreignKey="employees.EmployeeId" />
                          		<field name="ProjectId" type="integer" hidden="true" foreignKey="projects.ProjectId" />
                          		<field name="CompanyId" title="Company Id" type="sequence" foeignKey="companies.CompanyId" />
                          	</fields>

                          Comment


                            #14
                            Does the "getSelectedRecords()" method work for your requirements?
                            Code:
                                        public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
                                            final ListGridRecord[] selectedRecords = item.getSelectedRecords();
                                            for (ListGridRecord selectedRecord : selectedRecords) {
                                                final String selectedItemId = selectedRecord.getAttribute("EmployeeId");
                                                SC.say("Employee ID: " + selectedItemId);
                                            }
                                        }

                            Comment


                              #15
                              That workaround worked Joe!

                              Thanks for the help.

                              However I still believe the SelectItem object should take the toString() values of integers when doing SelectItem.getValues();

                              Either way thanks again!

                              Comment

                              Working...
                              X