Exemplo n.º 1
0
  public ActionForward save(
      ActionMapping mapping,
      ActionForm aform,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession(false);
    UserCredential credential = (UserCredential) session.getAttribute("Credential");
    StudAffairManager sam = (StudAffairManager) getBean("studAffairManager");
    ScoreManager sm = (ScoreManager) getBean("scoreManager");
    DynaActionForm form = (DynaActionForm) aform;

    String classInCharge = credential.getClassInChargeSqlFilterSAF();

    ActionMessages messages = validateInput(form);

    if (!messages.isEmpty()) {
      saveErrors(request, messages);
      session.setAttribute("ScoreSetDateEdit", form.getMap());
      return mapping.findForward("Main");
    } else {
      try {
        String level = form.getString("level");
        String levelSel = form.getString("levelSel");
        String depart = form.getString("depart");
        String departSel = form.getString("departSel");
        String beginDate = form.getString("beginDate");
        String beginTime = form.getString("beginTime");
        String endDate = form.getString("endDate");
        String endTime = form.getString("endTime");

        messages = sm.createUploadDateByForm(form);
        if (!messages.isEmpty()) {
          messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.CreateFailure"));
          saveErrors(request, messages);
          session.setAttribute("ScoreSetDateEdit", form.getMap());
          return mapping.findForward("Main");
        }

        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Message.CreateSuccessful"));
        saveMessages(request, messages);

        session.removeAttribute("ScoreSetDateEdit");
        return mapping.findForward("Main");
      } catch (Exception e) {
        ActionMessages errors = new ActionMessages();
        e.printStackTrace();
        errors.add(
            ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Exception.generic", e.getMessage()));
        saveErrors(request, errors);
        session.setAttribute("ScoreSetDateEdit", form.getMap());
        return mapping.findForward("Main");
      }
    }
  }
Exemplo n.º 2
0
  /**
   * @comment Action預設之執行方法
   * @param mapping org.apache.struts.action.ActionMapping object
   * @param form org.apache.struts.action.ActionForm object
   * @param request javax.servlet.http.HttpServletRequest object
   * @param response javax.servlet.http.HttpServletResponse object
   * @return org.apache.struts.action.ActionForward object
   * @exception java.lang.Exception
   */
  @Override
  public ActionForward unspecified(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    Map StudBonusPenaltyInfo = new HashMap();
    DynaActionForm dynForm = (DynaActionForm) form;
    HttpSession session = request.getSession(false);

    String opmode = dynForm.getString("opmode");
    if (opmode.equals("ok")) return save(mapping, form, request, response);
    else if (opmode.equals("cancel")) return cancel(mapping, form, request, response);

    StudAffairManager sm = (StudAffairManager) getBean("studAffairManager");

    UserCredential credential = (UserCredential) session.getAttribute("Credential");
    String classInCharge = credential.getClassInChargeSqlFilterSAF();
    setContentPage(session, "score/ScoreSetDateAdd.jsp");
    return mapping.findForward("Main");
  }