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);
     }
   }
 }