01: /*
02: @COPYRIGHT@
03: */
04: package demo.townsend.action;
05:
06: import demo.townsend.common.Constants;
07: import demo.townsend.service.DataKeeper;
08: import javax.servlet.http.HttpServletRequest;
09: import javax.servlet.http.HttpServletResponse;
10: import javax.servlet.http.HttpSession;
11: import org.apache.struts.action.Action;
12: import org.apache.struts.action.ActionForm;
13: import org.apache.struts.action.ActionForward;
14: import org.apache.struts.action.ActionMapping;
15: import org.apache.struts.action.DynaActionForm;
16:
17: /**
18: * DisplayUserListAction processes the request to display the user's list.
19: * User's list is fetched from the HttpSession object, and a dynamic form
20: * (i.e., displayUserListForm) is populated with this data.
21: */
22: public class DisplayUserListAction extends Action {
23: public ActionForward execute(ActionMapping mapping,
24: ActionForm form, HttpServletRequest request,
25: HttpServletResponse response) throws Exception {
26:
27: HttpSession session = request.getSession();
28:
29: DataKeeper dkeeper = (DataKeeper) session
30: .getAttribute(Constants.DATA_KEY);
31:
32: if (dkeeper == null) {
33: dkeeper = new DataKeeper();
34: }
35:
36: ((DynaActionForm) form).set("recentList", dkeeper.getList());
37: ((DynaActionForm) form).set("listLength", Integer
38: .toString(dkeeper.getListSize()));
39: ((DynaActionForm) form).set("currentProduct", dkeeper
40: .getCurrent());
41:
42: return mapping.findForward(Constants.SUCCESS_KEY);
43: }
44: }
|