コード例 #1
0
    public void execute(Event<UIPortlet> event) throws Exception {
      UIPortlet uiPortlet = event.getSource();

      String portletMode = null;

      Object changePortletModeAttribute =
          event.getRequestContext().getAttribute(CHANGE_PORTLET_MODE_EVENT);
      if (changePortletModeAttribute != null && changePortletModeAttribute instanceof String) {
        portletMode = (String) changePortletModeAttribute;
      }

      if (portletMode == null) {
        portletMode = event.getRequestContext().getRequestParameter(Constants.PORTAL_PORTLET_MODE);
      }
      if (portletMode == null) {
        portletMode = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
      }
      if (portletMode == null) {
        portletMode = uiPortlet.getCurrentPortletMode().toString();
      }

      log.trace(
          "Change portlet mode of " + uiPortlet.getPortletContext().getId() + " to " + portletMode);
      if (portletMode.equals(PortletMode.HELP.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.HELP);
      } else if (portletMode.equals(PortletMode.EDIT.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.EDIT);
      } else if (portletMode.equals(PortletMode.VIEW.toString())) {
        uiPortlet.setCurrentPortletMode(PortletMode.VIEW);
      } else {
        PortletMode customMode = new PortletMode(portletMode);
        uiPortlet.setCurrentPortletMode(customMode);
      }
      event.getRequestContext().addUIComponentToUpdateByAjax(uiPortlet);
    }
コード例 #2
0
  public String getEditModeContent() {
    StringBuilder portletContent = new StringBuilder();
    try {
      PortalRequestContext prcontext =
          (PortalRequestContext) WebuiRequestContext.getCurrentInstance();
      prcontext.ignoreAJAXUpdateOnPortlets(true);
      StatefulPortletContext portletContext = uiPortlet_.getPortletContext();

      ExoPortletInvocationContext portletInvocationContext =
          new ExoPortletInvocationContext(prcontext, uiPortlet_);

      List<Cookie> requestCookies =
          new ArrayList<Cookie>(Arrays.asList(prcontext.getRequest().getCookies()));

      PortletInvocation portletInvocation = uiPortlet_.create(RenderInvocation.class, prcontext);
      RenderInvocation renderInvocation = (RenderInvocation) portletInvocation;
      // make sure we are in the EDIT mode, and not whatever the current portlet mode is for the
      // Portlet
      renderInvocation.setMode(Mode.create(PortletMode.EDIT.toString()));

      PortletInvocationResponse portletResponse = uiPortlet_.invoke(renderInvocation);
      portletContent.append(uiPortlet_.generateRenderMarkup(portletResponse, prcontext).toString());
    } catch (Throwable ex) {
      WebuiRequestContext webuiRequest = WebuiRequestContext.getCurrentInstance();
      portletContent.append(
          webuiRequest.getApplicationResourceBundle().getString("UIPortlet.message.RuntimeError"));
      log.error(
          "The portlet "
              + uiPortlet_.getName()
              + " could not be loaded. Check if properly deployed.",
          ExceptionUtil.getRootCause(ex));
    }
    return portletContent.toString();
  }
コード例 #3
0
 /**
  * Activate mode.
  *
  * @param newMode the mode
  * @throws Exception the exception
  */
 public void activateMode(PortletMode newMode) throws Exception {
   if (getChild(UIPresentationContainer.class) != null) {
     removeChild(UIPresentationContainer.class);
   }
   if (getChild(UISCVPreferences.class) != null) {
     removeChild(UISCVPreferences.class);
   }
   if (PortletMode.VIEW.equals(newMode)) {
     PortletRequestContext pContext =
         (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
     uiPresentation =
         addChild(
             UIPresentationContainer.class,
             null,
             UIPresentationContainer.class.getSimpleName() + pContext.getWindowId());
   } else if (PortletMode.EDIT.equals(newMode)) {
     popPreferences = addChild(UISCVPreferences.class, null, null);
     popPreferences.setInternalPreferencesMode(true);
   }
 }