Announcement

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

    convertMapToJavascriptObject gives error on field with multiple = true?

    Hi,

    I am coming in JSOHelper.convertMapToJavascriptObject in the else throw new IllegalArgumentException("Unsupported type for attribute " + key + " : " + value) case for my multiple links fields.

    "Object value" in there is actually an ArrayList of Maps in my case.

    Should a case be added for ArrayList in that method on JSOHelper, or is there something deeply going wrong here?
    I've yet to try this with a link holding actually more than 1 destination objects, but I figure it'll be in an ArrayList as well.

    Code:
    <field name="theLinks" title="Link1" multiple="true" type="myLink" target="javascript" javaClass="zzz.MyLink" crud="2" required="false" dest="197" />
    Code:
    theLinks:[
    	{
    		dest:197, 
    		id:501268, 
    		repr:"1", 
    		status:0, 
    		rel:598
    	}
    ],

    bye,


    SmartClient Version: SC_SNAPSHOT-2010-09-10/EVAL Deployment

    #2
    I see you've got a very recent build, but regardless, can you try the latest in this instance? JSOHelper was just enhanced to cover many more cases 3 days ago.

    Comment


      #3
      Hi,

      Trying with build of 14/09, but I don't see a case for ArrayList in that method.
      I am trying to add a case myself and at one time to test things out I set the attribute to null so the callback to the server would work, but then I got this error:

      Code:
      java.lang.ClassCastException: org.apache.commons.collections.map.LinkedMap cannot be cast to java.util.Collection
      	at com.isomorphic.base.Reflection.adaptValue(Reflection.java:1115)
      	at com.isomorphic.util.DataTools.coerceProperty(DataTools.java:2597)
      	at com.isomorphic.util.DataTools.setProperties(DataTools.java:2419)
      	at com.isomorphic.util.DataTools.setProperties(DataTools.java:2331)

      Comment


        #4
        Hi,

        If this sounds OK to you guys, can you please add the following to com.smartgwt.client.util.JSOHelper as this seems to solve my issues.


        Method: public static JavaScriptObject convertToJavaScriptArray(Object[] array)
        add a case for Map:
        Code:
        } else if (val instanceof Map) {
        JSOHelper.setArrayValue(jsArray, i, convertMapToJavascriptObject((Map)val));

        Method: public static JavaScriptObject convertMapToJavascriptObject(Map valueMap)
        add a case for ArrayList (not sure if there's something better in JavaScript than ArrayList.toArray()?):
        Code:
        } else if (value instanceof ArrayList){
        setAttribute(valueJS, key, JSOHelper.convertToJavaScriptArray(((ArrayList)value).toArray()));

        best regards,
        Levi

        Comment


          #5
          I committed these changes. Please pick up the next nightly build.

          Thanks,
          Sanjiv

          Comment


            #6
            Cool, thanks Sanjiv, it works.

            Comment

            Working...
            X