I have a Smart GWT Project where the data that is to be displayed on screen, is stored in a class that is shared by client and server.
I read some docs at the Smart GWT website where they have explained how to connect to XML or JSON data sources.
What I want to do is link my POJO with the Smart GWT widget.
And the data is available client-side, so the server-side data communication component of Smart GWT(Which is only available in paid editions)is not needed.
What is the recommended way to go about implementing this? Are there any best practices while doing this? And am I correct in assuming that I can do the above with the Free edition of Smart GWT?
You must manually add a POJO's fields to attributes of record. We can not simply pass the object as a value in grid. I did it so:
greetingService
.getUsersList(new AsyncCallback<ArrayList<UserForRPC>>() {
public void onFailure(Throwable caught) {
}
public void onSuccess(ArrayList<UserForRPC> result) {
ListGridRecord[] listUsers = new ListGridRecord[result.size()];
int recordNum = 0;
for (UserForRPC user : result) {
ListGridRecord record = new ListGridRecord();
record.setAttribute("id", user.getId());
record.setAttribute("firstName", user.getFirstName());
record.setAttribute("lastName", user.getLastName());
record.setAttribute("login", user.getLogin());
record.setAttribute("password", user.getPassword());
record.setAttribute("email", user.getEmail());
record.setAttribute("role", user.getRole());
record.setAttribute("organization", user.getOrganization());
listUsers[recordNum++] = record;
}
usersGrid.setData(listUsers);
}
});