Announcement

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

    How to convert or cast ListGrid data to a List<Map>

    I'm trying to leverage some existing GWT java code that takes a parameter which is a java.util.List of java.util.Maps and updates it with new values. The list of maps I want to pass it is already stored in as the RecordList for a ListGrid via List.setData().

    What is the most efficient way to transform that RecordList into a simple List of Maps and then back again after the method updates it? Or is there a way to cast the RecordList as a List of Maps since that is essentially what it is already.

    #2
    You can't achieve this with a simple cast unfortunately.

    For now you can make use of the following helpers:
    - RecordList.toArray() will give you back the list as a Record[]
    - Record.getJsObj() will give you the underlying JavaScript object in question - you can turn that into a Map via JSOHelper.convertToMap()
    - To create a Record from a Map you can use JSOHelper.convertMapToJavascriptObject(...) and pass that to the Record constructor).
    - And there is a recordList constructor that takes a Record[]

    This does seem more complex than necessary. To simplify this we've just added the following APIs to simplify this (will show up in the next nightly build):

    Record.toMap() - converts a Record to a Map
    Record(Map recordProperties) - creates a Record from a Map

    Comment

    Working...
    X