Exemplo n.º 1
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);
 }
 @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);
     }
   }
 }