public static final String KEY_WATCHLIST_DATA = "watchListData";
@Override
public View handleRequest(HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) {
User user = Common.getUser(request);
WatchListDao watchListDao = new WatchListDao();
// Check for a watchlist id parameter. If given, update the user.
try {
int watchListId = Integer.parseInt(request.getParameter("watchListId"));
WatchList watchList = watchListDao.getWatchList(watchListId);
WatchListCommon.ensureWatchListPermission(user, watchList);
watchListDao.saveSelectedWatchList(user.getId(), watchList.getId());
}
catch (NumberFormatException e) {
// no op
}
prepareModel(request, model, user);
// Get the selected watchlist.
int watchListId = (Integer) model.get(KEY_SELECTED_WATCHLIST);
// Get the point data.
List<MobileWatchListState> states = new ArrayList<MobileWatchListState>();
for (DataPointVO pointVO : watchListDao.getWatchList(watchListId).getPointList()) {
MobileWatchListState state = createState(request, pointVO);
states.add(state);
}
model.put(KEY_WATCHLIST_DATA, states);