コード例 #1
0
  private void writeTagEventAttributes(
      FacesContext context, UIInput component, ResponseWriter writer, String currentValue)
      throws IOException {
    XspInputText tcomponent = (XspInputText) component;

    // write the FOCUS_ATTRS events onblur, onfocus,
    // and HTML_ATTRS onclick ondblclick
    String onfocus = tcomponent.getOnfocus();
    if (null != onfocus) {
      writer.writeAttribute("onfocus", onfocus, null); // $NON-NLS-1$
    }
    String onblur = tcomponent.getOnblur();
    if (null != onblur) {
      writer.writeAttribute("onblur", onblur, null); // $NON-NLS-1$
    }
    String onclick = tcomponent.getOnclick();
    if (null != onclick) {
      writer.writeAttribute("onclick", onclick, null); // $NON-NLS-1$
    }
    String ondblclick = tcomponent.getOndblclick();
    if (null != ondblclick) {
      writer.writeAttribute("ondblclick", ondblclick, null); // $NON-NLS-1$
    }
    // write the HTML_ATTRS key events
    String onkeydown = tcomponent.getOnkeydown();
    if (null != onkeydown) {
      writer.writeAttribute("onkeydown", onkeydown, null); // $NON-NLS-1$
    }
    String onkeypress = tcomponent.getOnkeypress();
    if (null != onkeypress) {
      writer.writeAttribute("onkeypress", onkeypress, null); // $NON-NLS-1$
    }
    String onkeyup = tcomponent.getOnkeyup();
    if (null != onkeyup) {
      writer.writeAttribute("onkeyup", onkeyup, null); // $NON-NLS-1$
    }

    // write the HTML_ATTRS mouse events
    String onmousedown = tcomponent.getOnmousedown();
    if (null != onmousedown) {
      writer.writeAttribute("onmousedown", onmousedown, null); // $NON-NLS-1$
    }
    String onmousemove = tcomponent.getOnmousemove();
    if (null != onmousemove) {
      writer.writeAttribute("onmousemove", onmousemove, null); // $NON-NLS-1$
    }
    String onmouseout = tcomponent.getOnmouseout();
    if (null != onmouseout) {
      writer.writeAttribute("onmouseout", onmouseout, null); // $NON-NLS-1$
    }
    String onmouseover = tcomponent.getOnmouseover();
    if (null != onmouseover) {
      writer.writeAttribute("onmouseover", onmouseover, null); // $NON-NLS-1$
    }
    String onmouseup = tcomponent.getOnmouseup();
    if (null != onmouseup) {
      writer.writeAttribute("onmouseup", onmouseup, null); // $NON-NLS-1$
    }

    // write the input-props events
    String onchange = tcomponent.getOnchange();
    if (null != onchange) {
      writer.writeAttribute("onchange", onchange, null); // $NON-NLS-1$
    }
    String onselect = tcomponent.getOnselect();
    if (null != onselect) {
      writer.writeAttribute("onselect", onselect, null); // $NON-NLS-1$
    }
  }
コード例 #2
0
  private void writeTagHtmlAttributes(
      FacesContext context, UIInput component, ResponseWriter writer, String currentValue)
      throws IOException {
    XspInputText tcomponent = (XspInputText) component;

    // this mostly encodes the same attributes as the superclass,
    // except for the event attributes, which are encoded in writeTagEventAttributes
    // and it also encodes the TEXT_ATTRS listed above.

    // accessKey
    String accesskey = tcomponent.getAccesskey();
    if (accesskey != null) {
      writer.writeAttribute("accesskey", accesskey, "accesskey"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // autoComplete
    String autoComplete = tcomponent.getAutocomplete();
    if (autoComplete != null) {
      // only output the autocomplete attribute if the value
      // is 'off' since its lack of presence will be interpreted
      // as 'on' by the browser
      if ("off".equals(autoComplete)) { // $NON-NLS-1$
        writer.writeAttribute(
            "autocomplete", "off", "autocomplete"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
    }

    // dir
    String dir = tcomponent.getDir();
    if (dir != null) {
      writer.writeAttribute("dir", dir, "dir"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // role
    String role = tcomponent.getRole();
    if (role != null) {
      writer.writeAttribute("role", role, "role"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // aria-required
    if (tcomponent.isRequired()) {
      writer.writeAttribute("aria-required", "true", null); // $NON-NLS-1$ //$NON-NLS-2$
    }

    // aria-invalid
    if (!tcomponent.isValid()) {
      writer.writeAttribute("aria-invalid", "true", null); // $NON-NLS-1$ //$NON-NLS-2$
    }

    // disabled.
    boolean disabled = tcomponent.isDisabled();
    if (disabled) {
      // note, write disabled="disabled" (not disabled="true")
      writer.writeAttribute(
          "disabled", "disabled", "disabled"); // $NON-NLS-1$ $NON-NLS-2$ //$NON-NLS-3$
    }

    // lang
    String lang = tcomponent.getLang();
    if (lang != null) {
      writer.writeAttribute("lang", lang, "lang"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // maxlength
    int maxlength = tcomponent.getMaxlength();
    if (maxlength >= 0) {
      writer.writeAttribute("maxlength", maxlength, "maxlength"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // readonly
    boolean readonly = ReadOnlyAdapterRenderer.isReadOnly(context, component);
    if (readonly) {
      writer.writeAttribute(
          "readonly", "readonly", "readonly"); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
    }

    // size
    int size = tcomponent.getSize();
    if (size >= 0) {
      writer.writeAttribute("size", size, "size"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // style
    String style = tcomponent.getStyle();
    if (style != null) {
      writer.writeAttribute("style", style, "style"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // styleClass
    String styleClass = tcomponent.getStyleClass();
    if (styleClass != null) {
      writer.writeAttribute("class", styleClass, "styleClass"); // $NON-NLS-2$ $NON-NLS-1$
    }

    // tabindex
    String tabindex = tcomponent.getTabindex();
    if (tabindex != null) {
      writer.writeAttribute("tabindex", tabindex, "tabindex"); // $NON-NLS-1$ $NON-NLS-2$
    }

    // title
    String title = tcomponent.getTitle();
    if (title != null) {
      writer.writeAttribute("title", title, "title"); // $NON-NLS-1$ $NON-NLS-2$
    }
  }