Package org.apache.myfaces.tobago.internal.component

Examples of org.apache.myfaces.tobago.internal.component.AbstractUIInput


    if (clientId.equals(page.getActionId())) {
      // this is a inputSuggest
      encodeAjax(facesContext, component);
    } else {

      AbstractUIInput input = (AbstractUIInput) component;

      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);

      final String currentValue = getCurrentValue(facesContext, input);
      final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
      if (LOG.isDebugEnabled()) {
        LOG.debug("currentValue = '"
            + (password && currentValue != null ? StringUtils.leftPad("", currentValue.length(), '*') : currentValue)
            + "'");
      }
      final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
      final boolean readonly = ComponentUtils.getBooleanAttribute(input, Attributes.READONLY);
      final boolean disabled = ComponentUtils.getBooleanAttribute(input, Attributes.DISABLED);

      // Todo: check for valid binding
      boolean renderAjaxSuggest = false;
      if (input instanceof UIIn) {
        renderAjaxSuggest = ((UIIn) input).getSuggestMethod() != null;
      }
      String id = input.getClientId(facesContext);
      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
      writer.startElement(HtmlElements.INPUT, input);
      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
      writer.writeNameAttribute(id);
      writer.writeIdAttribute(id);
      HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
      if (currentValue != null) {
        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
      }
      if (title != null) {
        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
      }
      int maxLength = 0;
      for (Validator validator : input.getValidators()) {
        if (validator instanceof LengthValidator) {
          LengthValidator lengthValidator = (LengthValidator) validator;
          maxLength = lengthValidator.getMaximum();
        }
      }
      if (maxLength > 0) {
        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
      }
      writer.writeAttribute(HtmlAttributes.READONLY, readonly);
      writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
      Integer tabIndex = input.getTabIndex();
      if (tabIndex != null) {
        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
      }
      Style style = new Style(facesContext, input);
      writer.writeStyleAttribute(style);

      final String placeholder = input.getPlaceholder();
      if (!disabled && !readonly && StringUtils.isNotBlank(placeholder)) {
        writer.writeAttribute(HtmlAttributes.PLACEHOLDER, placeholder, true);
      }

      HtmlRendererUtils.renderDojoDndItem(component, writer, true);
View Full Code Here


    if (clientId.equals(page.getActionId())) {
      // this is a inputSuggest
      encodeAjax(facesContext, component);
    } else {

      AbstractUIInput input = (AbstractUIInput) component;

      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);

      String currentValue = getCurrentValue(facesContext, input);
      if (LOG.isDebugEnabled()) {
        LOG.debug("currentValue = '" + currentValue + "'");
      }
      String type = ComponentUtils.getBooleanAttribute(input,
          Attributes.PASSWORD) ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;

      // Todo: check for valid binding
      boolean renderAjaxSuggest = false;
      if (input instanceof UIIn) {
        renderAjaxSuggest = ((UIIn) input).getSuggestMethod() != null;
      }
      String id = input.getClientId(facesContext);
      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
      writer.startElement(HtmlElements.INPUT, input);
      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
      writer.writeNameAttribute(id);
      writer.writeIdAttribute(id);
      HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
      if (currentValue != null) {
        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
      }
      if (title != null) {
        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
      }
      int maxLength = 0;
      for (Validator validator : input.getValidators()) {
        if (validator instanceof LengthValidator) {
          LengthValidator lengthValidator = (LengthValidator) validator;
          maxLength = lengthValidator.getMaximum();
        }
      }
      if (maxLength > 0) {
        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
      }
      writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input, Attributes.READONLY));
      writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input, Attributes.DISABLED));
      Integer tabIndex = input.getTabIndex();
      if (tabIndex != null) {
        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
      }
      Style style = new Style(facesContext, input);
      writer.writeStyleAttribute(style);
View Full Code Here

  }

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {

    final AbstractUIInput input = (AbstractUIInput) component;
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
    final String currentValue = getCurrentValue(facesContext, input);
    final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
    if (LOG.isDebugEnabled()) {
      LOG.debug("currentValue = '"
          + (password && currentValue != null ? StringUtils.leftPad("", currentValue.length(), '*') : currentValue)
          + "'");
    }
    final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;

    final String id = input.getClientId(facesContext);
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.INPUT, input);
    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
    writer.writeNameAttribute(id);
    writer.writeIdAttribute(id);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
    if (currentValue != null) {
      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
    }
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    int maxLength = 0;
    String pattern = null;
    for (Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
        /*if (validator instanceof RegexValidator) {
          RegexValidator regexValidator = (RegexValidator) validator;
          pattern = regexValidator.getPattern();
        }*/
    }
    if (maxLength > 0) {
      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
    }
    if (pattern != null) {
      writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
    }
    writer.writeAttribute(HtmlAttributes.READONLY, input.isReadonly());
    writer.writeAttribute(HtmlAttributes.DISABLED, input.isDisabled());
    Integer tabIndex = input.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    Style style = new Style(facesContext, input);
    writer.writeStyleAttribute(style);

    if (input instanceof AbstractUIIn && ((AbstractUIIn) input).getSuggest() != null) {
      writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
    }

    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
    writer.writeClassAttribute(Classes.create(input));
      /*if (component instanceof AbstractUIInput) {
       String onchange = HtmlUtils.generateOnchange((AbstractUIInput) component, facesContext);
       if (onchange != null) {
         // TODO: create and use utility method to write attributes without quoting
     //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
       }
     } */
    boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
    writer.writeAttribute(HtmlAttributes.REQUIRED, required);
    HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
    writeAdditionalAttributes(facesContext, writer, input);
    HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
    writer.endElement(HtmlElements.INPUT);
  }
View Full Code Here

    if (clientId.equals(page.getActionId())) {
      // this is a inputSuggest
      encodeAjax(facesContext, component);
    } else {

      AbstractUIInput input = (AbstractUIInput) component;

      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);

      String currentValue = getCurrentValue(facesContext, input);
      if (LOG.isDebugEnabled()) {
        LOG.debug("currentValue = '" + currentValue + "'");
      }
      String type = ComponentUtils.getBooleanAttribute(input,
          Attributes.PASSWORD) ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;

      // Todo: check for valid binding
      boolean renderAjaxSuggest = false;
      if (input instanceof UIIn) {
        renderAjaxSuggest = ((UIIn) input).getSuggestMethod() != null;
      }
      String id = input.getClientId(facesContext);
      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
      writer.startElement(HtmlElements.INPUT, input);
      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
      writer.writeNameAttribute(id);
      writer.writeIdAttribute(id);
      if (currentValue != null) {
        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
      }
      if (title != null) {
        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
      }
      int maxLength = 0;
      for (Validator validator : input.getValidators()) {
        if (validator instanceof LengthValidator) {
          LengthValidator lengthValidator = (LengthValidator) validator;
          maxLength = lengthValidator.getMaximum();
        }
      }
      if (maxLength > 0) {
        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
      }
      writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input, Attributes.READONLY));
      writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input, Attributes.DISABLED));
      Integer tabIndex = input.getTabIndex();
      if (tabIndex != null) {
        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
      }
      Style style = new Style(facesContext, input);
      writer.writeStyleAttribute(style);
View Full Code Here

    if (clientId.equals(page.getActionId())) {
      // this is a inputSuggest
      encodeAjax(facesContext, component);
    } else {

      AbstractUIInput input = (AbstractUIInput) component;

      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);

      String currentValue = getCurrentValue(facesContext, input);
      if (LOG.isDebugEnabled()) {
        LOG.debug("currentValue = '" + currentValue + "'");
      }
      String type = ComponentUtils.getBooleanAttribute(input,
          Attributes.PASSWORD) ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;

      // Todo: check for valid binding
      boolean renderAjaxSuggest = false;
      if (input instanceof UIIn) {
        renderAjaxSuggest = ((UIIn) input).getSuggestMethod() != null;
      }
      String id = input.getClientId(facesContext);
      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
      writer.startElement(HtmlElements.INPUT, input);
      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
      writer.writeNameAttribute(id);
      writer.writeIdAttribute(id);
      if (currentValue != null) {
        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
      }
      if (title != null) {
        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
      }
      int maxLength = 0;
      for (Validator validator : input.getValidators()) {
        if (validator instanceof LengthValidator) {
          LengthValidator lengthValidator = (LengthValidator) validator;
          maxLength = lengthValidator.getMaximum();
        }
      }
      if (maxLength > 0) {
        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
      }
      writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input, Attributes.READONLY));
      writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input, Attributes.DISABLED));
      Integer tabIndex = input.getTabIndex();
      if (tabIndex != null) {
        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
      }
      Style style = new Style(facesContext, input);
      writer.writeStyleAttribute(style);
View Full Code Here

    if (clientId.equals(page.getActionId())) {
      // this is a inputSuggest
      encodeAjax(facesContext, component);
    } else {

      AbstractUIInput input = (AbstractUIInput) component;

      String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);

      String currentValue = getCurrentValue(facesContext, input);
      if (LOG.isDebugEnabled()) {
        LOG.debug("currentValue = '" + currentValue + "'");
      }
      String type = ComponentUtils.getBooleanAttribute(input,
          Attributes.PASSWORD) ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;

      // Todo: check for valid binding
      boolean renderAjaxSuggest = false;
      if (input instanceof UIIn) {
        renderAjaxSuggest = ((UIIn) input).getSuggestMethod() != null;
      }
      String id = input.getClientId(facesContext);
      TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
      writer.startElement(HtmlElements.INPUT, input);
      writer.writeAttribute(HtmlAttributes.TYPE, type, false);
      writer.writeNameAttribute(id);
      writer.writeIdAttribute(id);
      if (currentValue != null) {
        writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
      }
      if (title != null) {
        writer.writeAttribute(HtmlAttributes.TITLE, title, true);
      }
      int maxLength = 0;
      for (Validator validator : input.getValidators()) {
        if (validator instanceof LengthValidator) {
          LengthValidator lengthValidator = (LengthValidator) validator;
          maxLength = lengthValidator.getMaximum();
        }
      }
      if (maxLength > 0) {
        writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
      }
      writer.writeAttribute(HtmlAttributes.READONLY, ComponentUtils.getBooleanAttribute(input, Attributes.READONLY));
      writer.writeAttribute(HtmlAttributes.DISABLED, ComponentUtils.getBooleanAttribute(input, Attributes.DISABLED));
      Integer tabIndex = input.getTabIndex();
      if (tabIndex != null) {
        writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
      }
      Style style = new Style(facesContext, input);
      writer.writeStyleAttribute(style);
View Full Code Here

  }

  @Override
  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {

    final AbstractUIInput input = (AbstractUIInput) component;
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
    final String currentValue = getCurrentValue(facesContext, input);
    final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
    if (LOG.isDebugEnabled()) {
      LOG.debug("currentValue = '" + (password ? StringUtils.repeat("*", currentValue.length()) : currentValue) "'");
    }
    final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
    final String id = input.getClientId(facesContext);
    final boolean readonly = input.isReadonly();
    final boolean disabled = input.isDisabled();

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.INPUT, input);
    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
    writer.writeNameAttribute(id);
    writer.writeIdAttribute(id);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
    if (currentValue != null) {
      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
    }
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    int maxLength = 0;
    final String pattern = null;
    for (final Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        final LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
        /*if (validator instanceof RegexValidator) {
          RegexValidator regexValidator = (RegexValidator) validator;
          pattern = regexValidator.getPattern();
        }*/
    }
    if (maxLength > 0) {
      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
    }
    if (pattern != null) {
      writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
    }
    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    final Integer tabIndex = input.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    final Style style = new Style(facesContext, input);
    writer.writeStyleAttribute(style);

    final String placeholder = input.getPlaceholder();
    if (!disabled && !readonly && StringUtils.isNotBlank(placeholder)) {
      writer.writeAttribute(HtmlAttributes.PLACEHOLDER, placeholder, true);
    }

    if (input instanceof AbstractUIIn && ((AbstractUIIn) input).getSuggest() != null) {
      writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
    }

    writer.writeClassAttribute(Classes.create(input));
      /*if (component instanceof AbstractUIInput) {
       String onchange = HtmlUtils.generateOnchange((AbstractUIInput) component, facesContext);
       if (onchange != null) {
         // TODO: create and use utility method to write attributes without quoting
     //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
       }
     } */
    final boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
    writer.writeAttribute(HtmlAttributes.REQUIRED, required);
    HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
    writeAdditionalAttributes(facesContext, writer, input);
    HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
    writer.endElement(HtmlElements.INPUT);
  }
View Full Code Here

  }

  @Override
  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {

    final AbstractUIInput input = (AbstractUIInput) component;
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
    final String currentValue = getCurrentValue(facesContext, input);
    final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
    if (LOG.isDebugEnabled()) {
      LOG.debug("currentValue = '" + (password ? StringUtils.repeat("*", currentValue.length()) : currentValue) "'");
    }
    final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
    final String id = input.getClientId(facesContext);
    final boolean readonly = input.isReadonly();
    final boolean disabled = input.isDisabled();

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.INPUT, input);
    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
    writer.writeNameAttribute(id);
    writer.writeIdAttribute(id);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
    if (currentValue != null) {
      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
    }
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    int maxLength = 0;
    final String pattern = null;
    for (final Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        final LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
        /*if (validator instanceof RegexValidator) {
          RegexValidator regexValidator = (RegexValidator) validator;
          pattern = regexValidator.getPattern();
        }*/
    }
    if (maxLength > 0) {
      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
    }
    if (pattern != null) {
      writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
    }
    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    final Integer tabIndex = input.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    final Style style = new Style(facesContext, input);
    writer.writeStyleAttribute(style);

    final String placeholder = input.getPlaceholder();
    if (!disabled && !readonly && StringUtils.isNotBlank(placeholder)) {
      writer.writeAttribute(HtmlAttributes.PLACEHOLDER, placeholder, true);
    }

    if (input instanceof AbstractUIIn && ((AbstractUIIn) input).getSuggest() != null) {
      writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
    }

    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
    writer.writeClassAttribute(Classes.create(input));
      /*if (component instanceof AbstractUIInput) {
       String onchange = HtmlUtils.generateOnchange((AbstractUIInput) component, facesContext);
       if (onchange != null) {
         // TODO: create and use utility method to write attributes without quoting
     //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
       }
     } */
    final boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
    writer.writeAttribute(HtmlAttributes.REQUIRED, required);
    HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
    writeAdditionalAttributes(facesContext, writer, input);
    HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
    writer.endElement(HtmlElements.INPUT);
  }
View Full Code Here

  }

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {

    final AbstractUIInput input = (AbstractUIInput) component;
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
    final String currentValue = getCurrentValue(facesContext, input);
    final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
    if (LOG.isDebugEnabled()) {
      LOG.debug("currentValue = '"
          + (password && currentValue != null ? StringUtils.leftPad("", currentValue.length(), '*') : currentValue)
          + "'");
    }
    final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
    final String id = input.getClientId(facesContext);
    final boolean readonly = input.isReadonly();
    final boolean disabled = input.isDisabled();

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.INPUT, input);
    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
    writer.writeNameAttribute(id);
    writer.writeIdAttribute(id);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
    if (currentValue != null) {
      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
    }
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    int maxLength = 0;
    String pattern = null;
    for (Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
        /*if (validator instanceof RegexValidator) {
          RegexValidator regexValidator = (RegexValidator) validator;
          pattern = regexValidator.getPattern();
        }*/
    }
    if (maxLength > 0) {
      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
    }
    if (pattern != null) {
      writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
    }
    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    Integer tabIndex = input.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    Style style = new Style(facesContext, input);
    writer.writeStyleAttribute(style);

    final String placeholder = input.getPlaceholder();
    if (!disabled && !readonly && StringUtils.isNotBlank(placeholder)) {
      writer.writeAttribute(HtmlAttributes.PLACEHOLDER, placeholder, true);
    }

    if (input instanceof AbstractUIIn && ((AbstractUIIn) input).getSuggest() != null) {
      writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
    }

    HtmlRendererUtils.renderDojoDndItem(component, writer, true);
    writer.writeClassAttribute(Classes.create(input));
      /*if (component instanceof AbstractUIInput) {
       String onchange = HtmlUtils.generateOnchange((AbstractUIInput) component, facesContext);
       if (onchange != null) {
         // TODO: create and use utility method to write attributes without quoting
     //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
       }
     } */
    boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);
    writer.writeAttribute(HtmlAttributes.REQUIRED, required);
    HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
    writeAdditionalAttributes(facesContext, writer, input);
    HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
    writer.endElement(HtmlElements.INPUT);
  }
View Full Code Here

  }

  @Override
  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {

    final AbstractUIInput input = (AbstractUIInput) component;
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, input);
    final String currentValue = getCurrentValue(facesContext, input);
    final boolean password = ComponentUtils.getBooleanAttribute(input, Attributes.PASSWORD);
    if (LOG.isDebugEnabled()) {
      LOG.debug("currentValue = '" + (password ? StringUtils.repeat("*", currentValue.length()) : currentValue) "'");
    }
    final String type = password ? HtmlInputTypes.PASSWORD : HtmlInputTypes.TEXT;
    final String id = input.getClientId(facesContext);
    final boolean readonly = input.isReadonly();
    final boolean disabled = input.isDisabled();
    final boolean required = ComponentUtils.getBooleanAttribute(input, Attributes.REQUIRED);

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    writer.startElement(HtmlElements.INPUT, input);
    writer.writeAttribute(HtmlAttributes.TYPE, type, false);
    writer.writeNameAttribute(id);
    writer.writeIdAttribute(id);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, input);
    if (currentValue != null) {
      writer.writeAttribute(HtmlAttributes.VALUE, currentValue, true);
    }
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    int maxLength = 0;
    final String pattern = null;
    for (final Validator validator : input.getValidators()) {
      if (validator instanceof LengthValidator) {
        final LengthValidator lengthValidator = (LengthValidator) validator;
        maxLength = lengthValidator.getMaximum();
      }
        /*if (validator instanceof RegexValidator) {
          RegexValidator regexValidator = (RegexValidator) validator;
          pattern = regexValidator.getPattern();
        }*/
    }
    if (maxLength > 0) {
      writer.writeAttribute(HtmlAttributes.MAXLENGTH, maxLength);
    }
    if (pattern != null) {
      writer.writeAttribute(HtmlAttributes.PATTERN, pattern, false);
    }
    writer.writeAttribute(HtmlAttributes.READONLY, readonly);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    final Integer tabIndex = input.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    final Style style = new Style(facesContext, input);
    writer.writeStyleAttribute(style);

    final String placeholder = input.getPlaceholder();
    if (!disabled && !readonly && StringUtils.isNotBlank(placeholder)) {
      writer.writeAttribute(HtmlAttributes.PLACEHOLDER, placeholder, true);
    }

    if (input instanceof AbstractUIIn && ((AbstractUIIn) input).getSuggest() != null) {
      writer.writeAttribute(HtmlAttributes.AUTOCOMPLETE, "off", false);
    }

    writer.writeClassAttribute(Classes.create(input));
      /*if (component instanceof AbstractUIInput) {
       String onchange = HtmlUtils.generateOnchange((AbstractUIInput) component, facesContext);
       if (onchange != null) {
         // TODO: create and use utility method to write attributes without quoting
     //      writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, null);
       }
     } */
    writer.writeAttribute(HtmlAttributes.REQUIRED, required);
    HtmlRendererUtils.renderFocus(id, input.isFocus(), ComponentUtils.isError(input), facesContext, writer);
    writeAdditionalAttributes(facesContext, writer, input);
    HtmlRendererUtils.renderCommandFacet(input, facesContext, writer);
    writer.endElement(HtmlElements.INPUT);
  }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.internal.component.AbstractUIInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.