protected void encodeMarkup(FacesContext context, Editor editor) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    String clientId = editor.getClientId(context);
    String valueToRender = ComponentUtils.getValueToRender(context, editor);
    String inputId = clientId + "_input";

    String style = editor.getStyle();
    style = style == null ? "visibility:hidden" : "visibility:hidden;" + style;

    writer.startElement("div", editor);
    writer.writeAttribute("id", clientId, null);
    writer.writeAttribute("style", style, null);
    if (editor.getStyleClass() != null) {
      writer.writeAttribute("class", editor.getStyleClass(), null);
    }

    writer.startElement("textarea", null);
    writer.writeAttribute("id", inputId, null);
    writer.writeAttribute("name", inputId, null);

    if (valueToRender != null) {
      writer.write(valueToRender);
    }

    writer.endElement("textarea");

    writer.endElement("div");
  }
  @Override
  public void decode(FacesContext context, UIComponent component) {
    Editor editor = (Editor) component;
    String inputParam = editor.getClientId(context) + "_input";
    Map<String, String> params = context.getExternalContext().getRequestParameterMap();
    String value = params.get(inputParam);

    if (value != null && value.equals("<br/>")) {
      value = "";
    }

    editor.setSubmittedValue(value);
  }
  private void encodeScript(FacesContext context, Editor editor) throws IOException {
    String clientId = editor.getClientId(context);
    WidgetBuilder wb = getWidgetBuilder(context);
    wb.initWithDomReady("Editor", editor.resolveWidgetVar(), clientId, "editor")
        .attr("disabled", editor.isDisabled(), false)
        .attr("invalid", editor.isValid(), true)
        .attr("controls", editor.getControls(), null)
        .attr("width", editor.getWidth(), Integer.MIN_VALUE)
        .attr("height", editor.getHeight(), Integer.MIN_VALUE)
        .attr("maxlength", editor.getMaxlength(), Integer.MAX_VALUE)
        .callback("change", "function(e)", editor.getOnchange());

    if (AgentUtils.isIE(context)) {
      Resource resource =
          context
              .getApplication()
              .getResourceHandler()
              .createResource("editor/editor-ie.css", "primefaces");
      wb.attr("docCSSFile", resource.getRequestPath());
    }

    wb.finish();
  }