Announcement

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

    ListGridRecord setAttribute with List<obj>

    Hi,
    I was using SmartGwt 3.1 up to about two weeks ago, and I have a code generator that creates ListGridRecord objects from many types of DTOs in my application. Some of these DTOs contained List<> and Set<> objects. The code generator would do this on the ListGridRecord object:

    Code:
    this.setAttribute( ATTRIBUTES.CONFIGJOBS.toString(), dto.getConfigJobs() );
    where dto.getConfigJobs() returns a List<ConfigJobDTO>

    This was working fine with SmartGWT 2.5 and 3.1.

    After the upgrade to 4.0, I got this error when calling setAttribute() with the List<> as a parameter:

    Code:
    java.lang.UnsupportedOperationException: Can not convert element 0 of the array to a JavaScriptObject. Instances of class `com.test.ListDTO' can not automatically be converted. Please see the SmartClient documentation of RPCRequest.data for a table of Java types that can be converted automatically.
    Now I found a workaround doing this instead:

    Code:
    com.smartgwt.client.util.JSOHelper.setObjectAttribute(this.getJsObj(),ATTRIBUTES.CONFIGJOBS.toString(), dto.getConfigJobs() );
    I was wondering if there was an explanation to why this behavior has changed, and is this a safe way of putting a List of objects into a ListGridRecord attribute ?

    I am using Firefox and Chrome and both have the same behavior.

    Thank you

    #2
    ListGridRecord.setAttribute() is generally used for supplying values that can be accessed and displayed by DataBoundComponents, and as such does some automatic conversion from Java object types to JavaScript equivalents. This was recently expanded to include converting Lists to JavaScript arrays.

    However we recognize that there is a valid requirement to support storing out Java data types directly on Record objects in some cases and will be adding a method to do this in the near future.
    Watch this thread for updates.

    Regards
    Isomorphic Software

    Comment

    Working...
    X