/** Does all the prep work before showing the form */
  @RequestMapping(params = "action=addAnnouncement")
  public String showAddAnnouncementForm(
      @RequestParam(value = "editId", required = false) Long editId,
      @RequestParam(value = "topicId", required = false) Long topicId,
      RenderRequest request,
      Model model)
      throws PortletException {

    PortletPreferences prefs = request.getPreferences();

    if (!model.containsAttribute("announcement")) {
      Announcement ann = new Announcement();
      Topic topic = null;

      if (editId != null) {
        try {
          log.debug(
              "editId found. This is an edit request for announcement Id " + editId.toString());
          ann = announcementService.getAnnouncement(editId);
          // return immediately when we have our announcement

        } catch (NumberFormatException e) {
          log.debug("No editId found. This is not an edit request");
        }
      }

      if (ann != null && ann.getParent() == null) {
        try {
          topic = announcementService.getTopic(topicId);
          ann.setParent(topic);
        } catch (NumberFormatException e) {
          log.error("Unable to get topicId from request");
        }
      }

      model.addAttribute("announcement", ann);
    }

    model.addAttribute("datePickerFormat", datePickerFormat);
    model.addAttribute(
        "abstractMaxLength",
        prefs.getValue(PREFERENCE_ABSTRACT_MAX_LENGTH, DEFAULT_ABSTRACT_MAX_LENGTH));
    model.addAttribute(
        "tinyMceInitializationOptions",
        prefs.getValue(
            PREFERENCE_TINY_MCE_INITIALIZATION_OPTIONS, DEFAULT_TINY_MCE_INITIALIZATION_OPTIONS));
    return "addAnnouncement";
  }
示例#2
0
 /**
  * Process an action request.
  *
  * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest,
  *     javax.portlet.ActionResponse)
  */
 public void processAction(ActionRequest request, ActionResponse response)
     throws PortletException, java.io.IOException {
   if (request.getParameter(FORM_SUBMIT) != null) {
     // Set form text in the session bean
     Vlado2PortletSessionBean sessionBean = getSessionBean(request);
     if (sessionBean != null) sessionBean.setFormText(request.getParameter(FORM_TEXT));
   }
   if (request.getParameter(EDIT_SUBMIT) != null) {
     PortletPreferences prefs = request.getPreferences();
     try {
       prefs.setValue(EDIT_KEY, request.getParameter(EDIT_TEXT));
       prefs.store();
     } catch (ReadOnlyException roe) {
     } catch (ValidatorException ve) {
     }
   }
   if (request.getParameter(CONFIG_SUBMIT) != null) {
     PortletPreferences prefs = request.getPreferences();
     try {
       prefs.setValue(CONFIG_KEY, request.getParameter(CONFIG_TEXT));
       prefs.store();
     } catch (ReadOnlyException roe) {
     } catch (ValidatorException ve) {
     }
   }
 }
 public boolean getAllowEmptyMessage(PortletRequest req) {
   PortletPreferences prefs = req.getPreferences();
   return Boolean.parseBoolean(prefs.getValue(PREFERENCE_ALLOW_EMPTY_MESSAGE, "false"));
 }
 public boolean getAllowOpenEndDate(PortletRequest req) {
   PortletPreferences prefs = req.getPreferences();
   return Boolean.parseBoolean(prefs.getValue(PREFERENCE_ALLOW_OPEN_ENDDATE, "false"));
 }
  // set the Portlet's default View
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    PortletPreferences prefs = renderRequest.getPreferences();

    String typeUtility = (String) prefs.getValue("typeUtility", "");

    String chkStreetView = (String) prefs.getValue("chkStreetView", "");
    log.info("chkStreetView: " + chkStreetView);
    String chkZoom = (String) prefs.getValue("chkZoom", "");
    log.info("chkZoom: " + chkZoom);
    String chkDraggable = (String) prefs.getValue("chkDraggable", "");
    log.info("chkDraggable: " + chkDraggable);
    String chkPanControl = (String) prefs.getValue("chkPanControl", "");
    log.info("chkPanControl: " + chkPanControl);
    String chkRotateControl = (String) prefs.getValue("chkRotateControl", "");
    log.info("chkRotateControl: " + chkRotateControl);
    String chkScaleControl = (String) prefs.getValue("chkScaleControl", "");
    log.info("chkScaleControl: " + chkScaleControl);

    String typeMap = (String) prefs.getValue("typeMap", "");

    String address = (String) prefs.getValue("address", "");
    String descriptionMarker = (String) prefs.getValue("descriptionMarker", "");
    String typeIcon = (String) prefs.getValue("typeIcon", "");

    String fromAddress = (String) prefs.getValue("fromAddress", "");
    String toAddress = (String) prefs.getValue("toAddress", "");

    String notDefinedMessage = (String) prefs.getValue("notDefinedMessage", "");

    /* Default value */
    if (typeUtility.equals("")) {
      notDefinedMessage = "click on Preferences";
      renderRequest.setAttribute("notDefinedMessage", notDefinedMessage);
    } else if (typeUtility.equals("OneMarker")) {

      renderRequest.setAttribute("typeUtility", typeUtility);

      renderRequest.setAttribute("chkStreetView", chkStreetView);
      renderRequest.setAttribute("chkZoom", chkZoom);
      renderRequest.setAttribute("chkDraggable", chkDraggable);
      renderRequest.setAttribute("chkPanControl", chkPanControl);
      renderRequest.setAttribute("chkRotateControl", chkRotateControl);
      renderRequest.setAttribute("chkScaleControl", chkScaleControl);

      renderRequest.setAttribute("typeMap", typeMap);

      renderRequest.setAttribute("address", address);
      renderRequest.setAttribute("descriptionMarker", descriptionMarker);
      renderRequest.setAttribute("typeIcon", typeIcon);

      renderRequest.setAttribute("fromAddress", null);
      renderRequest.setAttribute("toAddress", null);

      renderRequest.setAttribute("notDefinedMessage", new String(""));

    } else if (typeUtility.equals("GetRoute")) {

      renderRequest.setAttribute("typeUtility", typeUtility);

      renderRequest.setAttribute("chkStreetView", chkStreetView);
      renderRequest.setAttribute("chkZoom", chkZoom);
      renderRequest.setAttribute("chkDraggable", chkDraggable);
      renderRequest.setAttribute("chkPanControl", chkPanControl);
      renderRequest.setAttribute("chkRotateControl", chkRotateControl);
      renderRequest.setAttribute("chkScaleControl", chkScaleControl);

      renderRequest.setAttribute("typeMap", typeMap);

      renderRequest.setAttribute("address", null);
      renderRequest.setAttribute("descriptionMarker", null);
      renderRequest.setAttribute("typeIcon", null);

      renderRequest.setAttribute("fromAddress", fromAddress);
      renderRequest.setAttribute("toAddress", toAddress);

      renderRequest.setAttribute("notDefinedMessage", new String(""));
    }

    include(viewJSP, renderRequest, renderResponse);
  }
  /* ACTION call from Portlet's <form> of EDIT JSP */
  public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException {

    String saveSettingsGoogleMapsUtility =
        actionRequest.getParameter("saveSettingsGoogleMapsUtility");
    /*You can add other getParameter of EDIT JSP*/

    if (saveSettingsGoogleMapsUtility != null) {
      PortletPreferences prefs = actionRequest.getPreferences();

      if (actionRequest.getParameter("inTypeUtility") != null)
        prefs.setValue("typeUtility", actionRequest.getParameter("inTypeUtility"));

      if (actionRequest.getParameter("inStreetView") != null)
        prefs.setValue("chkStreetView", actionRequest.getParameter("inStreetView"));
      if (actionRequest.getParameter("inZoom") != null)
        prefs.setValue("chkZoom", actionRequest.getParameter("inZoom"));
      if (actionRequest.getParameter("inDraggable") != null)
        prefs.setValue("chkDraggable", actionRequest.getParameter("inDraggable"));
      if (actionRequest.getParameter("inPanControl") != null)
        prefs.setValue("chkPanControl", actionRequest.getParameter("inPanControl"));
      if (actionRequest.getParameter("inRotateControl") != null)
        prefs.setValue("chkRotateControl", actionRequest.getParameter("inRotateControl"));
      if (actionRequest.getParameter("inScaleControl") != null)
        prefs.setValue("chkScaleControl", actionRequest.getParameter("inScaleControl"));

      if (actionRequest.getParameter("inTypeMap") != null)
        prefs.setValue("typeMap", actionRequest.getParameter("inTypeMap"));

      if (actionRequest.getParameter("inAddress") != null)
        prefs.setValue("address", actionRequest.getParameter("inAddress"));
      if (actionRequest.getParameter("inDescriptionMarker") != null)
        prefs.setValue("descriptionMarker", actionRequest.getParameter("inDescriptionMarker"));
      if (actionRequest.getParameter("inTypeIcon") != null)
        prefs.setValue("typeIcon", actionRequest.getParameter("inTypeIcon"));

      if (actionRequest.getParameter("inFromAddress") != null)
        prefs.setValue("fromAddress", actionRequest.getParameter("inFromAddress"));
      if (actionRequest.getParameter("inToAddress") != null)
        prefs.setValue("toAddress", actionRequest.getParameter("inToAddress"));

      prefs.store();
      actionResponse.setPortletMode(PortletMode.VIEW);
    }
  }