// not impacted by custom behaviour by default
 protected FaceletHandler getBareOptionFaceletHandler(
     FaceletContext ctx,
     FaceletHandlerHelper helper,
     Widget widget,
     WidgetSelectOption selectOption,
     FaceletHandler nextHandler) {
   String componentType = getOptionComponentType(selectOption);
   TagAttributes attrs = helper.getTagAttributes(selectOption);
   return helper.getHtmlComponentHandler(
       widget.getTagConfigId(), attrs, nextHandler, componentType, null);
 }
Ejemplo n.º 2
0
 @Test
 public void testGenerateUniqueId() throws Exception {
   MockFacesContext faces = new MockFacesContext();
   faces.mapExpression("#{" + NuxeoLayoutIdManagerBean.NAME + "}", new NuxeoLayoutIdManagerBean());
   String unique_1 = FaceletHandlerHelper.generateUniqueId(faces, "foo");
   assertEquals("foo", unique_1);
   String unique_2 = FaceletHandlerHelper.generateUniqueId(faces, "foo");
   assertEquals("foo_1", unique_2);
   // ask for a name already incremented
   String unique_3 = FaceletHandlerHelper.generateUniqueId(faces, "foo_1");
   assertEquals("foo_2", unique_3);
   // again with several levels
   String unique_4 = FaceletHandlerHelper.generateUniqueId(faces, "foo_1_1");
   assertEquals("foo_3", unique_4);
 }
Ejemplo n.º 3
0
 /** Component handler that displays an error on interface */
 public ComponentHandler getErrorComponentHandler(String tagConfigId, String errorMessage) {
   FaceletHandler leaf = new LeafFaceletHandler();
   TagAttribute valueAttr =
       createAttribute(
           "value",
           "<span style=\"color:red;font-weight:bold;\">ERROR: " + errorMessage + "</span><br />");
   TagAttribute escapeAttr = createAttribute("escape", "false");
   ComponentHandler output =
       getHtmlComponentHandler(
           tagConfigId,
           FaceletHandlerHelper.getTagAttributes(valueAttr, escapeAttr),
           leaf,
           HtmlOutputText.COMPONENT_TYPE,
           null);
   return output;
 }
  protected void apply(
      FaceletContext ctx,
      UIComponent parent,
      Widget widget,
      String componentType,
      String rendererType)
      throws WidgetException, IOException {
    FaceletHandlerHelper helper = new FaceletHandlerHelper(tagConfig);
    String mode = widget.getMode();
    String widgetId = widget.getId();
    String widgetName = widget.getName();
    String widgetTagConfigId = widget.getTagConfigId();
    List<String> excludedProps = getExcludedProperties();
    TagAttributes attributes = helper.getTagAttributes(widget, excludedProps, true);
    // BBB for CSS style classes on directory select components
    if (widget.getProperty("cssStyle") != null) {
      attributes =
          FaceletHandlerHelper.addTagAttribute(
              attributes, helper.createAttribute("style", (String) widget.getProperty("cssStyle")));
    }
    if (widget.getProperty("cssStyleClass") != null) {
      attributes =
          FaceletHandlerHelper.addTagAttribute(
              attributes,
              helper.createAttribute("styleClass", (String) widget.getProperty("cssStyleClass")));
    }
    if (!BuiltinWidgetModes.isLikePlainMode(mode)) {
      attributes =
          FaceletHandlerHelper.addTagAttribute(attributes, helper.createAttribute("id", widgetId));
    }
    if (BuiltinWidgetModes.EDIT.equals(mode)) {
      FaceletHandler optionsHandler = getOptionsFaceletHandler(ctx, helper, widget);
      FaceletHandler[] nextHandlers = new FaceletHandler[] {};
      nextHandlers = (FaceletHandler[]) ArrayUtils.add(nextHandlers, optionsHandler);
      FaceletHandler leaf =
          getNextHandler(ctx, tagConfig, widget, nextHandlers, helper, true, true);
      // maybe add convert handler for easier integration of select2
      // widgets handling multiple values
      if (HtmlSelectManyListbox.COMPONENT_TYPE.equals(componentType)
          || HtmlSelectManyCheckbox.COMPONENT_TYPE.equals(componentType)
          || HtmlSelectManyMenu.COMPONENT_TYPE.equals(componentType)) {
        // add hint for value conversion to collection
        attributes =
            FaceletHandlerHelper.addTagAttribute(
                attributes, helper.createAttribute("collectionType", ArrayList.class.getName()));
      }

      ComponentHandler input =
          helper.getHtmlComponentHandler(
              widgetTagConfigId, attributes, leaf, componentType, rendererType);
      String msgId = FaceletHandlerHelper.generateMessageId(ctx, widgetName);
      ComponentHandler message =
          helper.getMessageComponentHandler(widgetTagConfigId, msgId, widgetId, null);
      FaceletHandler[] handlers = {getComponentFaceletHandler(ctx, helper, widget, input), message};
      FaceletHandler h = new CompositeFaceletHandler(handlers);
      h.apply(ctx, parent);
    } else {
      // TODO
      return;
    }
  }
 @Override
 public void apply(FaceletContext ctx, UIComponent parent, Widget widget)
     throws WidgetException, IOException {
   FaceletHandlerHelper helper = new FaceletHandlerHelper(tagConfig);
   String mode = widget.getMode();
   String widgetId = widget.getId();
   String widgetName = widget.getName();
   String widgetTagConfigId = widget.getTagConfigId();
   TagAttributes attributes;
   if (BuiltinWidgetModes.isLikePlainMode(mode)) {
     // use attributes without id
     attributes = helper.getTagAttributes(widget);
   } else {
     if (BuiltinWidgetModes.EDIT.equals(mode)) {
       // exclude styleClass, it needs a specific css class also, see
       // below
       attributes = helper.getTagAttributes(widget, Arrays.asList("styleClass"), true);
       attributes =
           FaceletHandlerHelper.addTagAttribute(
               attributes, helper.createAttribute("id", widgetId));
     } else {
       attributes = helper.getTagAttributes(widgetId, widget);
     }
   }
   FaceletHandler leaf = getNextHandler(ctx, tagConfig, widget, null, helper);
   if (BuiltinWidgetModes.EDIT.equals(mode)) {
     ComponentHandler input =
         helper.getHtmlComponentHandler(
             widgetTagConfigId, attributes, leaf, UIHtmlEditor.COMPONENT_TYPE, null);
     String msgId = FaceletHandlerHelper.generateMessageId(ctx, widgetName);
     ComponentHandler message =
         helper.getMessageComponentHandler(widgetTagConfigId, msgId, widgetId, null);
     FaceletHandler[] handlers = {input, message};
     FaceletHandler h = new CompositeFaceletHandler(handlers);
     h.apply(ctx, parent);
   } else {
     // default on text for other modes, do not escape
     TagAttribute escape = helper.createAttribute("escape", "false");
     attributes = FaceletHandlerHelper.addTagAttribute(attributes, escape);
     String styleClass = (String) widget.getProperty("styleClass");
     TagAttribute styleClassAttr =
         helper.createAttribute(
             "styleClass",
             StringUtils.isBlank(styleClass) ? "textBlock" : "textBlock " + styleClass);
     attributes = FaceletHandlerHelper.addTagAttribute(attributes, styleClassAttr);
     ComponentHandler output =
         helper.getHtmlComponentHandler(
             widgetTagConfigId, attributes, leaf, HtmlOutputText.COMPONENT_TYPE, null);
     if (BuiltinWidgetModes.PDF.equals(mode)) {
       // add a surrounding p:html tag handler
       FaceletHandler h =
           helper.getHtmlComponentHandler(
               widgetTagConfigId,
               new TagAttributesImpl(new TagAttribute[0]),
               output,
               UIHtmlText.class.getName(),
               null);
       h.apply(ctx, parent);
     } else {
       output.apply(ctx, parent);
     }
   }
 }
Ejemplo n.º 6
0
 @Override
 public void apply(FaceletContext ctx, UIComponent parent)
     throws IOException, FacesException, FaceletException, ELException {
   FaceletHandlerHelper helper = new FaceletHandlerHelper(config);
   TagAttributes devAttrs =
       FaceletHandlerHelper.getTagAttributes(
           helper.createAttribute("id", FaceletHandlerHelper.generateDevContainerId(ctx, refId)),
           helper.createAttribute("styleClass", "displayN nxlDevContainer"),
           helper.createAttribute("layout", "block"));
   ComponentHandler dComp =
       helper.getHtmlComponentHandler(
           config.getTagId(), devAttrs, devHandler, PANEL_COMPONENT_TYPE, null);
   FaceletHandler nextHandler =
       new CompositeFaceletHandler(
           new FaceletHandler[] {
             helper.getDisableDevModeTagHandler(config.getTagId(), dComp), originalHandler
           });
   TagAttributes cAttrs =
       FaceletHandlerHelper.getTagAttributes(
           helper.createAttribute("id", FaceletHandlerHelper.generateDevRegionId(ctx, refId)),
           helper.createAttribute("styleClass", "nxlDevRegion"),
           helper.createAttribute("layout", "block"));
   ComponentHandler cComp =
       helper.getHtmlComponentHandler(
           config.getTagId(), cAttrs, nextHandler, PANEL_COMPONENT_TYPE, null);
   cComp.apply(ctx, parent);
 }