Ejemplo n.º 1
0
  /** Update or delete survey. */
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    setUpData(request);

    Survey survey = (Survey) request.getAttribute(RequestUtils.SURVEY);
    String action = RequestUtils.getAlphaInput(request, "action", "Action", true);
    ResourceBundle bundle = ResourceBundle.getBundle("Text");

    // Process based on action
    if (!StringUtils.isEmpty(action)) {
      if (action.equals(bundle.getString("updateLabel"))) {

        // Fields
        String name =
            RequestUtils.getAlphaInput(request, "name", bundle.getString("nameLabel"), true);
        survey.setName(name);

        updateAction(request, response);
      } else if (action.equals(bundle.getString("deleteLabel"))) {
        deleteAction(request, response);
      }
    } else {
      RequestUtils.forwardTo(request, response, ControllerConstants.SURVEYS_REDIRECT);
    }
  }