1 package org.springframework.samples.jpetstore.web.struts; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionForward; 8 import org.apache.struts.action.ActionMapping; 9 10 import org.springframework.samples.jpetstore.domain.Account; 11 12 public class NewAccountFormAction extends BaseAction { 13 14 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 15 AccountActionForm workingAcctForm = new AccountActionForm(); 16 request.getSession().removeAttribute("workingAccountForm"); 17 request.getSession().setAttribute("workingAccountForm", workingAcctForm); 18 if (workingAcctForm.getAccount() == null) { 19 workingAcctForm.setAccount(new Account()); 20 } 21 if (workingAcctForm.getCategories() == null) { 22 workingAcctForm.setCategories(getPetStore().getCategoryList()); 23 } 24 return mapping.findForward("success"); 25 } 26 27 } 28 | Popular Tags |