Search code examples
gwtsmartgwt

SmartGWT 3.0 testdata to 3.x?


In SmartGWT 3.0, setting testdata had a DataClass[] parameter. An example would be this:

public void loadUsers(List<User> params) {
    this.users = new HashMap<String, User>();

    UserDC[] items = new UserDC[params.size()];

    int i = 0;
    for(User item : params) {
        users.put(item.getUsername(), item);
        items[i] = new UserDC(item);
        i++;
    }
    setTestData(items);
}

How do I do this in SmartGWT 3.1?


Solution

  • In SmartGWT 3.1, the DataClass[] parameter was replaced by a Record… parameter. The way I fixed this is by converting each DataClass object to a Javascript Object and collecting them in a Record Array. Like this:

    public void loadUsers(List<User> params) {
            this.users = new HashMap<String, User>();
    
            Record[] items = new Record[params.size()];
    
            int i = 0;
            for(User item : params) {
                users.put(item.getUsername(), item);
                items[i] = new Record(new UserDC(item).getJsObj());
                i++;
            }
    
    
            setTestData(items);
    
        }