Ejemplo n.º 1
0
  /* (non-Javadoc)
   * @see org.apache.struts.actions.DispatchAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    if (request.getSession().getAttribute("userId") == null) {

      System.out.println("userid123" + request.getSession().getAttribute("userId"));
      response.sendRedirect("/sec/Login.do");
    }
    Long aptid = (Long) request.getSession().getAttribute("aptID");
    MaintenanceRequestForm maintenfrm = (MaintenanceRequestForm) form;
    ApartmentDAO aptDAO = new ApartmentDAO();
    Apartment Apt = aptDAO.findById(aptid);
    maintenfrm.setApartment(Apt.getApartmentNumber());
    HttpSession session = request.getSession();
    session.setAttribute("ApartmentNo", maintenfrm.getApartment());
    System.out.println("userid" + request.getSession().getAttribute("userId"));

    System.out.println("a:" + request.getParameter("r:" + mapping.getParameter()));
    if (FormUtil.isNotNull(request.getParameter(mapping.getParameter()))
        && request.getParameter(mapping.getParameter()).equals("Submit")) {
      System.out.println("/////" + request.getParameter(mapping.getParameter()));
      return this.submit(mapping, form, request, response);
    } else {
      UserDAO userDAO = new UserDAO();
      User user = userDAO.findById((Long) request.getSession().getAttribute("userId"));
      MaintenanceRequestForm requestForm = new MaintenanceRequestForm();
      requestForm = (MaintenanceRequestForm) form;
      requestForm.setContactNo(user.getHomePhone());
      return mapping.findForward("input");
    }
  }