コード例 #1
0
ファイル: PersonAction.java プロジェクト: nmsgit1234/bsip
  public ActionForward updatePersonInfo(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:updatePersonInfo() ");

    // If user pressed 'Cancel' button,
    // return to home page

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    // Person personObj = new Person();

    // PropertyUtils.copyProperties(personObj, (PersonForm)form);

    try {
      PersonManager clientHandler = new PersonManager();

      Person oldPersonObj = clientHandler.getPerson(((PersonForm) form).getId().toString());
      CommonLogger.logDebug(log, "the retrieved person id is " + oldPersonObj.getId());
      PropertyUtils.copyProperties(oldPersonObj, (PersonForm) form);
      clientHandler.updatePersonInfo(oldPersonObj);
      ActionMessages msgs = new ActionMessages();
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("common.update.succesfull"));
      saveMessages(request, msgs);
    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:updatePersonInfo() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    } finally {
      request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.EDIT);
    }

    return mapping.findForward("success");
  }