Пример #1
0
  /**
   * This method gets a single TerminationReason Record from database based on given
   * TerminationReason recordId
   *
   * @param actionRequest
   * @param actionResponse
   * @throws IOException
   * @throws PortletException
   * @throws NumberFormatException
   * @throws PortalException
   * @throws SystemException
   */
  public void editTerminationReasons(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException, NumberFormatException, PortalException,
          SystemException {
    Long terminationreasonsId = ParamUtil.getLong(actionRequest, "terminationreasonsId");
    TerminationReasons terminationReasons =
        TerminationReasonsLocalServiceUtil.getTerminationReasons(terminationreasonsId);

    actionRequest.setAttribute("editTerminationReasons", terminationReasons);
    actionResponse.setRenderParameter("jspPage", "/html/terminationreasons/edit.jsp");
  }
Пример #2
0
  /**
   * This method updates the TerminationReason record based on TerminationReason recordId
   *
   * @param actionRequest
   * @param actionResponse
   * @throws IOException
   * @throws PortletException
   * @throws SystemException
   */
  public void updateTerminationReasons(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException, SystemException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String id = ParamUtil.getString(actionRequest, "terminationreasonsId");
    String name = ParamUtil.getString(actionRequest, "terminationreasonsName");
    System.out.println("id == " + id);
    TerminationReasons terminationReasons;

    try {
      String terminationReason = name.trim();
      if (terminationReason.equals("") || terminationReason == null) {

        System.out.println("Empty value in TerminationReason...");
        TerminationReasons terminationReasons2 =
            TerminationReasonsLocalServiceUtil.getTerminationReasons(Long.parseLong(id));

        actionRequest.setAttribute("editTerminationReasons", terminationReasons2);

        SessionMessages.add(actionRequest.getPortletSession(), "termination-form-error");
        actionResponse.setRenderParameter("mvcPath", "/html/terminationreasons/edit.jsp");
      } else {

        terminationReasons =
            TerminationReasonsLocalServiceUtil.getTerminationReasons(Long.parseLong(id));
        terminationReasons.setCreateDate(date);
        terminationReasons.setModifiedDate(date);
        terminationReasons.setCompanyId(themeDisplay.getCompanyId());
        terminationReasons.setGroupId(themeDisplay.getCompanyGroupId());
        terminationReasons.setUserId(themeDisplay.getUserId());
        terminationReasons.setTerminationreasonsName(name);
        terminationReasons =
            TerminationReasonsLocalServiceUtil.updateTerminationReasons(terminationReasons);
      }
    } catch (NumberFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (PortalException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }