1 4 package demo.townsend.action; 5 6 import demo.townsend.common.Constants; 7 import demo.townsend.service.DataKeeper; 8 import javax.servlet.http.HttpServletRequest ; 9 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 22 public class DisplayUserListAction extends Action { 23 public ActionForward execute( ActionMapping mapping, ActionForm form, 24 HttpServletRequest request, HttpServletResponse response) 25 throws Exception { 26 27 HttpSession session = request.getSession(); 28 29 DataKeeper dkeeper = (DataKeeper) session.getAttribute(Constants.DATA_KEY ); 30 31 if(dkeeper == null) { 32 dkeeper = new DataKeeper(); 33 } 34 35 ((DynaActionForm)form).set( "recentList", dkeeper.getList()); 36 ((DynaActionForm)form).set( "listLength", Integer.toString(dkeeper.getListSize())); 37 ((DynaActionForm)form).set( "currentProduct", dkeeper.getCurrent()); 38 39 return mapping.findForward( Constants.SUCCESS_KEY ); 40 } 41 } 42 | Popular Tags |