예제 #1
0
  public String event(String name, String componentId, String beanId) throws Exception {
    StringBuilder b = new StringBuilder();
    // TODO: Tung.Pham modified
    // ------------------------
    b.append("javascript:");
    WebuiRequestContext rcontext = WebuiRequestContext.getCurrentInstance();
    UIComponent subComponent = findComponentById(componentId);
    org.exoplatform.webui.config.Event event =
        subComponent.getComponentConfig().getUIComponentEventConfig(name);
    if (event == null) {
      return "??config??";
    }
    String confirm = event.getConfirm();
    if (confirm != null && confirm.trim().length() > 0) {
      try {
        confirm = rcontext.getApplicationResourceBundle().getString(confirm);
      } catch (MissingResourceException exp) {
        confirm = confirm.substring(confirm.lastIndexOf('.') + 1);
      }
      b.append("if(confirm('").append(confirm.replaceAll("'", "\\\\'")).append("'))");
    }
    b.append("eXo.webui.UIForm.submitEvent('").append(getFormId()).append("','");
    // b.append("javascript:eXo.webui.UIForm.submitEvent('").append(getId()).append("','");
    // -------------------------

    b.append(name).append("','");
    b.append("&").append(SUBCOMPONENT_ID).append("=").append(componentId);
    if (beanId != null) {
      b.append("&").append(OBJECTID).append("=").append(beanId);
    }
    b.append("')");
    return b.toString();
  }
예제 #2
0
    @Override
    public void execute(Event<UITabContainer> event) throws Exception {
      UITabContainer container = event.getSource();
      PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
      if (container == null) {
        return;
      }

      List<UIComponent> children = container.getChildren();
      for (UIComponent child : children) {
        if (child.isRendered() && child instanceof UIContainer) {
          UIContainer newTabContainer = container.addChild(UIContainer.class, null, null);
          newTabContainer.setTemplate(child.getTemplate());
          child.setRendered(false);
          newTabContainer.setRendered(true);
          newTabContainer.setId(String.valueOf(newTabContainer.hashCode()));
          pcontext.addUIComponentToUpdateByAjax(container);
          pcontext
              .getJavascriptManager()
              .require("SHARED/portal", "portal")
              .addScripts("portal.PortalComposer.toggleSaveButton();");
          return;
        }
      }
    }
예제 #3
0
 private UIComponent addUIExtension(UIExtension extension, Map<String, Object> context)
     throws Exception {
   UIExtensionManager manager = getApplicationComponent(UIExtensionManager.class);
   UIComponent component = manager.addUIExtension(extension, context, this);
   if (component == null) return null;
   synchronized (component) {
     if (component instanceof UIAbstractManagerComponent) {
       // You can access to the given extension and the extension is valid
       UIAbstractManagerComponent uiAbstractManagerComponent =
           (UIAbstractManagerComponent) component;
       uiAbstractManagerComponent.setUIExtensionName(extension.getName());
       uiAbstractManagerComponent.setUIExtensionCategory(extension.getCategory());
       return component;
     } else if (component != null) {
       // You can access to the given extension but the extension is not valid
       if (LOG.isWarnEnabled()) {
         LOG.warn(
             "All the extension '"
                 + extension.getName()
                 + "' of type '"
                 + EXTENSION_TYPE
                 + "' must be associated to a component of type "
                 + UIAbstractManagerComponent.class);
       }
       removeChild(component.getClass());
     }
   }
   return null;
 }
예제 #4
0
 public void execute(Event<UIAddAttachment> event) throws Exception {
   UIAddAttachment component = event.getSource();
   EventUIComponent eventUIComponent = component.getTargetAttachEvent();
   UIPortletApplication portlet = component.getAncestorOfType(UIPortletApplication.class);
   UIComponent targerComponent = portlet.findComponentById(eventUIComponent.getId());
   Event<UIComponent> xEvent =
       targerComponent.createEvent(
           eventUIComponent.getEventName(), Event.Phase.PROCESS, event.getRequestContext());
   if (!StringUtils.isEmpty(getSelectedFile(event))) {
     processEvent(event);
   } else {
     event
         .getRequestContext()
         .getUIApplication()
         .addMessage(
             new ApplicationMessage(
                 "UIAddAttachment.msg.not-a-file", null, ApplicationMessage.WARNING));
     ((PortalRequestContext) event.getRequestContext().getParentAppRequestContext())
         .ignoreAJAXUpdateOnPortlets(true);
     return;
   }
   if (xEvent != null) {
     xEvent.broadcast();
   }
   UIPopupWindow uiPopupWindow = event.getSource().getParent();
   uiPopupWindow.setRendered(false);
   uiPopupWindow.setUIComponent(null);
   event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupWindow.getParent());
 }
 @Override
 public void renderChildren() throws Exception {
   List<UIComponent> list = getChildren();
   for (UIComponent child : list) {
     if (!(child instanceof UISEOToolbarForm) && child.isRendered()) {
       renderChild(child);
     }
   }
 }
예제 #6
0
 public void execute(Event<UISearchBasisPortlet> event) throws Exception {
   UISearchBasisPortlet uiSearchBasisPortlet = event.getSource();
   String id = event.getRequestContext().getRequestParameter(OBJECTID);
   if (id == null) return;
   for (UIComponent uicomponent : uiSearchBasisPortlet.getChildren()) {
     if (!uicomponent.getId().equals(id)) {
       uicomponent.setRendered(false);
     } else {
       uicomponent.setRendered(true);
     }
   }
   event.getRequestContext().addUIComponentToUpdateByAjax(uiSearchBasisPortlet);
 }
 public void processAction(UIStandaloneApplication uicomponent, WebuiRequestContext context)
     throws Exception {
   String componentId = context.getRequestParameter(context.getUIComponentIdParameterName());
   if (componentId == null) {
     return;
   }
   UIComponent uiTarget = uicomponent.findComponentById(componentId);
   if (uiTarget == null) {
     return;
   }
   if (uiTarget == uicomponent) {
     super.processAction(uicomponent, context);
   }
   uiTarget.processAction(context);
 }
 public void processDecode(UIStandaloneApplication uicomponent, WebuiRequestContext context)
     throws Exception {
   String componentId = context.getRequestParameter(context.getUIComponentIdParameterName());
   if (componentId == null) {
     return;
   }
   UIComponent uiTarget = uicomponent.findComponentById(componentId);
   if (uiTarget == null) {
     context.addUIComponentToUpdateByAjax(uicomponent.getChild(UIStandaloneAppContainer.class));
     return;
   }
   if (uiTarget == uicomponent) {
     super.processDecode(uicomponent, context);
   }
   uiTarget.processDecode(context);
 }
예제 #9
0
 public static List<String> getAllLanguages(UIComponent component) {
   LocaleConfigService configService =
       component.getApplicationComponent(LocaleConfigService.class);
   List<String> languages = new ArrayList<String>();
   for (LocaleConfig localeConfig : configService.getLocalConfigs()) {
     languages.add(localeConfig.getLocale().getDisplayLanguage());
   }
   return languages;
 }
예제 #10
0
 public void validate(UIFormInput uiInput) throws Exception {
   if (uiInput.getValue() == null || ((String) uiInput.getValue()).trim().length() == 0) return;
   UIComponent uiComponent = (UIComponent) uiInput;
   UIForm uiForm = uiComponent.getAncestorOfType(UIForm.class);
   String label;
   try {
     label = uiForm.getLabel(uiInput.getName());
   } catch (Exception e) {
     label = uiInput.getName();
   }
   label = label.trim();
   if (label.charAt(label.length() - 1) == ':') label = label.substring(0, label.length() - 1);
   String s = (String) uiInput.getValue();
   if (s == null || s.trim().length() == 0) {
     Object[] args = {uiInput.getLabel()};
     throw new MessageException(
         new ApplicationMessage(
             "ECMNameValidator.msg.empty-input", args, ApplicationMessage.WARNING));
   }
   for (int i = 0; i < s.length(); i++) {
     char c = s.charAt(i);
     if (Character.isLetter(c)
         || Character.isDigit(c)
         || Character.isSpaceChar(c)
         || c == '_'
         || c == '-'
         || c == '.'
         || c == ':'
         || c == '@'
         || c == '^'
         || c == '['
         || c == ']'
         || c == ',') {
       continue;
     }
     Object[] args = {label};
     throw new MessageException(
         new ApplicationMessage(
             "ECMNameValidator.msg.Invalid-char", args, ApplicationMessage.WARNING));
   }
 }
    public void execute(Event<UISocialGroupSelector> event) throws Exception {
      UISocialGroupSelector uiSelector = event.getSource();
      UIComponent uiPermission = uiSelector.<UIComponent>getParent().getParent();
      WebuiRequestContext pcontext = event.getRequestContext();

      UIPopupWindow uiPopup = uiSelector.getParent();
      UIForm uiForm = event.getSource().getAncestorOfType(UIForm.class);
      if (uiForm != null) {
        event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
      } else {
        event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup);
      }
      if (uiSelector.getCurrentGroup() == null) {
        UIApplication uiApp = pcontext.getUIApplication();
        uiApp.addMessage(new ApplicationMessage("UIGroupSelector.msg.selectGroup", null));
        // pcontext.addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages());
        uiPopup.setShow(true);
        return;
      }

      uiPermission.broadcast(event, event.getExecutionPhase());
      uiPopup.setShow(false);
    }
예제 #12
0
 /* (non-Javadoc)
  * @see org.exoplatform.webui.core.UIComponent#processRender(org.exoplatform.webui.application.WebuiRequestContext)
  */
 public void processRender(WebuiRequestContext context) throws Exception {
   if (getComponentConfig() != null) {
     super.processRender(context);
     return;
   }
   UIForm uiForm = getAncestorOfType(UIForm.class);
   Writer writer = context.getWriter();
   writer.write("<div class=\"" + getId() + "\">");
   writer.write("<fieldset>");
   writer.write("<legend>" + uiForm.getLabel(getId()) + "</legend>");
   writer.write("<table class=\"UIFormGrid\">");
   for (UIComponent component : getChildren()) {
     if (component.isRendered()) {
       writer.write("<tr>");
       String componentName = uiForm.getLabel(component.getId());
       if (componentName != null && componentName.length() > 0 && !componentName.equals(getId())) {
         writer.write(
             "<td class=\"FieldLabel\"><label for=\""
                 + component.getId()
                 + "\">"
                 + componentName
                 + "</td>");
         writer.write("<td class=\"FieldComponent\">");
         renderUIComponent(component);
         writer.write("</td>");
       } else {
         writer.write("<td class=\"FieldComponent\" colspans=\"2\">");
         renderUIComponent(component);
         writer.write("</td>");
       }
       writer.write("</tr>");
     }
   }
   writer.write("</table>");
   writer.write("</fieldset>");
   writer.write("</div>");
 }
 @SuppressWarnings("unchecked")
 public static ModelObject buildModelObject(UIComponent uiComponent) {
   ModelObject model = null;
   try {
     model = uiComponent.buildModelObject();
   } catch (UnsupportedOperationException ex) {
     if (uiComponent instanceof UIPortal) {
       model = toPortal((UIPortal) uiComponent);
     } else if (uiComponent instanceof UIPageBody) {
       model = new PageBody(((UIPageBody) uiComponent).getStorageId());
     } else if (uiComponent instanceof UIPage) {
       model = toPageModel((UIPage) uiComponent);
     } else if (uiComponent instanceof UIPortlet) {
       model = toPortletModel((UIPortlet<Object, ?>) uiComponent);
     } else if (uiComponent instanceof UIContainer) {
       model = toContainer((UIContainer) uiComponent);
     } else if (uiComponent instanceof UIGadget) {
       model = toGadget((UIGadget) uiComponent);
     }
   }
   return model;
 }
예제 #14
0
 public void execute(Event<UITabContainer> event) throws Exception {
   String objectId = event.getRequestContext().getRequestParameter(OBJECTID);
   UITabContainer container = event.getSource();
   UIComponent goal = container.findComponentById(objectId);
   if (goal == null) {
     return;
   }
   UITabContainer parent = goal.getParent();
   List<UIComponent> children = parent.getChildren();
   for (UIComponent child : children) {
     if (child.getId().equals(objectId)) {
       child.setRendered(true);
       continue;
     }
     child.setRendered(false);
   }
 }
예제 #15
0
 public void renderField(UIComponent uiInput) throws Exception {
   WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
   uiInput.processRender(context);
 }
 public void processRender(WebuiRequestContext context) throws Exception {
   init();
   super.processRender(context);
 }
예제 #17
0
 /* (non-Javadoc)
  * @see org.exoplatform.webui.core.UIComponent#processDecode(org.exoplatform.webui.application.WebuiRequestContext)
  */
 public void processDecode(WebuiRequestContext context) throws Exception {
   for (UIComponent child : getChildren()) {
     child.processDecode(context);
   }
 }
  /**
   * The processrender() method handles the creation of the returned HTML either for a full page
   * render or in the case of an AJAX call The first request, Ajax is not enabled (means no
   * ajaxRequest parameter in the request) and hence the super.processRender() method is called.
   * This will hence call the processrender() of the Lifecycle object as this method is not
   * overidden in UIPortalApplicationLifecycle. There we simply render the bounded template (groovy
   * usually). Note that bounded template are also defined in component annotations, so for the
   * current class it is UIPortalApplication.gtmpl On second calls, request have the "ajaxRequest"
   * parameter set to true in the URL. In that case the algorithm is a bit more complex: a) The list
   * of components that should be updated is extracted using the
   * context.getUIComponentToUpdateByAjax() method. That list was setup during the process action
   * phase b) Portlets and other UI components to update are split in 2 different lists c) Portlets
   * full content are returned and set with the tag <div class="PortalResponse"> d) Block to updates
   * (which are UI components) are set within the <div class="PortalResponseData"> tag e) Then the
   * scripts and the skins to reload are set in the <div class="PortalResponseScript">
   */
  public void processRender(WebuiRequestContext context) throws Exception {
    Writer w = context.getWriter();
    if (!context.useAjax()) {
      super.processRender(context);
    } else {
      PortalRequestContext pcontext = (PortalRequestContext) context;

      UIMaskWorkspace uiMaskWS = getChildById(UIPortalApplication.UI_MASK_WS_ID);
      if (uiMaskWS.isUpdated()) pcontext.addUIComponentToUpdateByAjax(uiMaskWS);
      if (getUIPopupMessages().hasMessage()) {
        pcontext.addUIComponentToUpdateByAjax(getUIPopupMessages());
      }

      Set<UIComponent> list = context.getUIComponentToUpdateByAjax();
      List<UIPortlet> uiPortlets = new ArrayList<UIPortlet>(3);
      List<UIComponent> uiDataComponents = new ArrayList<UIComponent>(5);

      if (list != null) {
        for (UIComponent uicomponent : list) {
          if (uicomponent instanceof UIPortlet) uiPortlets.add((UIPortlet) uicomponent);
          else uiDataComponents.add(uicomponent);
        }
      }
      w.write("<div class=\"PortalResponse\">");
      w.write("<div class=\"PortalResponseData\">");
      for (UIComponent uicomponent : uiDataComponents) {
        if (log.isDebugEnabled())
          log.debug("AJAX call: Need to refresh the UI component " + uicomponent.getName());
        renderBlockToUpdate(uicomponent, context, w);
      }
      w.write("</div>");

      if (!context.getFullRender()) {
        for (UIPortlet uiPortlet : uiPortlets) {
          if (log.isDebugEnabled())
            log.debug("AJAX call: Need to refresh the Portlet " + uiPortlet.getWindowId());

          w.write("<div class=\"PortletResponse\" style=\"display: none\">");
          w.append(
              "<div class=\"PortletResponsePortletId\">"
                  + uiPortlet.getExoWindowID().getUniqueID()
                  + "</div>");
          w.append("<div class=\"PortletResponseData\">");

          /*
           * If the portlet is using our UI framework or supports it then it
           * will return a set of block to updates. If there is not block to
           * update the javascript client will see that as a full refresh of the
           * content part
           */
          uiPortlet.processRender(context);

          w.append("</div>");
          w.append("<div class=\"PortletResponseScript\"></div>");
          w.write("</div>");
        }
      }

      w.write("<div class=\"PortalResponseScript\">");
      w.write(pcontext.getJavascriptManager().getJavascript());
      w.write("eXo.core.Browser.onLoad();\n");
      w.write(pcontext.getJavascriptManager().getCustomizedOnLoadScript());
      String skin = getAddSkinScript(list);
      if (skin != null) {
        w.write(skin);
      }
      w.write("</div>");
      w.write("</div>");
    }
  }