Announcement

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

    Exception when setting setValueMap in ListGridField

    Hello there,

    I am trying to get the data for my Listgrid from the java class instead from the Datasource field. But I get this exception

    Code:
    10:48:49.274 [ERROR] [kaizenbehsa] Uncaught exception escaped
    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
        at com.smartgwt.client.util.JSOHelper.convertMapToJavascriptObject(JSOHelper.java:1309)
        at com.smartgwt.client.util.JSOHelper.convertMapToJavascriptObject(JSOHelper.java:1302)
        at com.smartgwt.client.util.JSOHelper.setAttribute(JSOHelper.java:1297)
        at com.smartgwt.client.core.DataClass.setAttribute(DataClass.java:311)
        at com.smartgwt.client.widgets.grid.ListGridField.setValueMap(ListGridField.java:3924)
        at com.behsa.client.view.datamanagement.menu.ProductionLineView.initLayout(ProductionLineView.java:42)
        at com.behsa.client.view.datamanagement.menu.ProductionLineView.<init>(ProductionLineView.java:28)
        at com.behsa.client.view.datamanagement.menu.ProductionLineController.initView(ProductionLineController.java:22)
    My java code is like so

    Code:
    DataSource ds = DataSource.get("productionlineDS");
    
    		listgrid = new MyListGrid();
    		listgrid.setDataSource(ds);
    		
    		ListGridField name = new ListGridField("name");
    		ListGridField bize = new ListGridField("bize");
    		
    		ListGridField pu = new ListGridField("pu");
    		pu.setValueMap(CommonUtil.unitComboValueMap);
    		
    		ListGridField ways = new ListGridField("ways");
    		
    		listgrid.setFields(name,bize,pu,ways);
    Code:
    public static final LinkedHashMap<Integer, String> unitComboValueMap = new LinkedHashMap<Integer, String>();
    
    static{				
    		unitComboValueMap.put(0,"Gram");
    		unitComboValueMap.put(1, "Liter");	
    		unitComboValueMap.put(3,"Pcs");
    		unitComboValueMap.put(4, "Other");
    	}
    and my datasource is

    Code:
    <DataSource ID="productionlineDS" serverType="sql" tableName="proine">
    	<fields>
    		<field name="id" type="sequence" hidden="true" primaryKey="true" />
    		<field name="name"  type="ntext" required="true"/>
    		<field name="bize"  type="integer" required="true"/>
    		<field name="pu" type="integer" required="true"/>
            <field name="ways" type="integer" required="true"/>
    	</fields>
    </DataSource>

    #2
    When you file a bug report, you need to provide us with the exact version of SGWT that you're using. This means the branch and date of the build that you've installed.

    Comment


      #3
      Hi Isomorphic,

      I am using SmartClient Version: v10.0p_2015-05-08/PowerEdition Deployment (built 2015-05-08) with FF26.

      cheers
      Zolf

      Comment


        #4
        Hi Isomorphic,

        Can you please give me feedback on my issue.

        Cheers
        Zolf

        Comment


          #5
          The exception is being thrown because the SGWT Framework expects the keys to be Strings. We're going to make a change to allow Integer keys as well - this will likely be available in tomorrow's nightly build.

          Comment


            #6
            Hi Isomorphic,

            Thanks fot your feedback.

            Cheers
            Zolf

            Comment


              #7
              This has been fixed in SGWT 5.0p and newer and will be available in the nightly builds marked 06-26-2015. (The exception has been suppressed in todays builds, but some additional changes are needed.)

              Comment

              Working...
              X