Prev | Current Page 677 | Next

Frank Zammetti

"Practical DWR 2 Projects"

executeQuery(SQL_GET_GROUPS_LIST,
new HashMap());
List groupList = new ArrayList();
for (Map m : groups) {
GroupDescriptor group = new GroupDescriptor();
group.setGroupName((String)m.get("GROUPNAME"));
CHAPTER 7 n ENTER THE ENTERPRISE: A DWR-BASED REPORT PORTAL 395
group.setDescription((String)m.get("DESCRIPTION"));
groupList.add(group);
}
return groupList;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
This is again pretty typical code like we??™ve seen before, but this time you??™ll note we??™re
returning a List not of strings, but of a specified data type: GroupDescriptor. The callback on
the client uses these objects to populate the list of groups. You may have cause to wonder why
I didn??™t have a FavoritesDescriptor and return a List of those from the getFavoritesForUser()
method in the FavoritesWorker class. The answer is simply that it??™s a good way to show a different
approach to the same basic need, so for demonstration purposes it was useful. There??™s
probably no technical reason this method and the other couldn??™t have both been done the
same way, whichever way you prefer. But hey, this is a book, you??™re supposed to be exposed to
new ideas, and like Seven of Nine, you can never have too many curves (and if you??™re a lady
reading this, you can think of the curves on Jean-Luc Picard??™s bald head, I suppose).


Pages:
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689