Package javax.faces.component

Examples of javax.faces.component.ValueHolder


            // PENDING i18n
            throw new JspException("Can't create class of type:"+
                    "javax.faces.convert.Converter for:"+converterError);
        }

        ValueHolder vh = (ValueHolder)component;
        FacesContext context = FacesContext.getCurrentInstance();
       
        // Register an instance with the appropriate component
        vh.setConverter(converter);
       
        // Once the converter has been set, attempt to convert the
        // incoming "value"
        Object localValue = vh.getLocalValue();
        if (localValue instanceof String) {
            try {
                localValue = converter.getAsObject(context, (UIComponent)vh, (String) localValue);
                vh.setValue(localValue);
            }
            catch (ConverterException ce) {
                // PENDING - Ignore?  Throw an exception?  Set the local
                // value back to "null" and log a warning?
            }
View Full Code Here


        if (converter == null) {
            throw new JspException("Can't create class of type:"+
                    " javax.faces.convert.Converter, converter is null");
        }
       
        ValueHolder vh = (ValueHolder)component;
        FacesContext context = FacesContext.getCurrentInstance();
       
        // Register an instance with the appropriate component
        vh.setConverter(converter);
       
        // Once the converter has been set, attempt to convert the
        // incoming "value"
        Object localValue = vh.getLocalValue();
        if (localValue instanceof String) {
            try {
                localValue = converter.getAsObject(context, (UIComponent)vh, (String) localValue);
                vh.setValue(localValue);
            }
            catch (ConverterException ce) {
                // PENDING - Ignore?  Throw an exception?  Set the local
                // value back to "null" and log a warning?
            }
View Full Code Here

    if (value instanceof String) {
      return (String) value;
    }
    Converter converter = null;
    if (component instanceof ValueHolder) {
      ValueHolder holder = (ValueHolder) component;
      converter = holder.getConverter();
    }
    if (null == converter && null != value) {
      try {
        converter = context.getApplication().createConverter(
            value.getClass());
View Full Code Here

        // Retrieve the current FaceletContext from FacesContext object
        FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(
                FaceletContext.FACELET_CONTEXT_KEY);
       
        // cast to a ValueHolder
        ValueHolder vh = (ValueHolder) parent;
        ValueExpression ve = null;
        Converter c = null;
        if (_delegate.getBinding() != null)
        {
            ve = _delegate.getBinding().getValueExpression(faceletContext, Converter.class);
            c = (Converter) ve.getValue(faceletContext);
        }
        if (c == null)
        {
            c = this.createConverter(faceletContext);
            if (ve != null)
            {
                ve.setValue(faceletContext, c);
            }
        }
        if (c == null)
        {
            throw new TagException(_delegate.getTag(), "No Converter was created");
        }
        _delegate.setAttributes(faceletContext, c);
        vh.setConverter(c);
        Object lv = vh.getLocalValue();
        FacesContext faces = faceletContext.getFacesContext();
        if (lv instanceof String)
        {
            vh.setValue(c.getAsObject(faces, parent, (String) lv));
        }
    }
View Full Code Here

        // Retrieve the current FaceletContext from FacesContext object
        FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(
                FaceletContext.FACELET_CONTEXT_KEY);
       
        // cast to a ValueHolder
        ValueHolder vh = (ValueHolder) parent;
        ValueExpression ve = null;
        Converter c = null;
        if (_delegate.getBinding() != null)
        {
            ve = _delegate.getBinding().getValueExpression(faceletContext, Converter.class);
            c = (Converter) ve.getValue(faceletContext);
        }
        if (c == null)
        {
            c = this.createConverter(faceletContext);
            if (ve != null)
            {
                ve.setValue(faceletContext, c);
            }
        }
        if (c == null)
        {
            throw new TagException(_delegate.getTag(), "No Converter was created");
        }
        _delegate.setAttributes(faceletContext, c);
        vh.setConverter(c);
        Object lv = vh.getLocalValue();
        FacesContext faces = faceletContext.getFacesContext();
        if (lv instanceof String)
        {
            vh.setValue(c.getAsObject(faces, parent, (String) lv));
        }
    }
View Full Code Here

        // Retrieve the current FaceletContext from FacesContext object
        FaceletContext faceletContext = (FaceletContext) context.getAttributes().get(
                FaceletContext.FACELET_CONTEXT_KEY);
       
        // cast to a ValueHolder
        ValueHolder vh = (ValueHolder) parent;
        ValueExpression ve = null;
        Converter c = null;
        if (_delegate.getBinding() != null)
        {
            ve = _delegate.getBinding().getValueExpression(faceletContext, Converter.class);
            c = (Converter) ve.getValue(faceletContext);
        }
        if (c == null)
        {
            c = this.createConverter(faceletContext);
            if (ve != null)
            {
                ve.setValue(faceletContext, c);
            }
        }
        if (c == null)
        {
            throw new TagException(_delegate.getTag(), "No Converter was created");
        }
        _delegate.setAttributes(faceletContext, c);
        vh.setConverter(c);
        Object lv = vh.getLocalValue();
        FacesContext faces = faceletContext.getFacesContext();
        if (lv instanceof String)
        {
            vh.setValue(c.getAsObject(faces, parent, (String) lv));
        }
    }
View Full Code Here

      {
        // sometimes we might have to return the date/number as a string.
        // see bug 4602629:
        if (expectedType == String.class)
        {
          ValueHolder holder = (ValueHolder) component;
          // if the submitted string is identical to the existing string
          // then there is no need to convert: bug 4620622:
          if (strValue.equals(holder.getValue()))
            return strValue;
          return converter.getAsString(context, component, value);
        } else
        {
          GenericConverterFactory fac = GenericConverterFactory
View Full Code Here

    return onclick;
  }

  public static String appendConfirmationScript(String onclick,
      UIComponent component, FacesContext facesContext) {
    ValueHolder confirmation
        = (ValueHolder) component.getFacet(TobagoConstants.FACET_CONFIRMATION);
    if (confirmation != null) {
      if (onclick != null) {
        onclick = "confirm('" + confirmation.getValue() + "') && " + onclick;
      } else {
        if (LOG.isWarnEnabled()) {
          LOG.warn("Facet '" + TobagoConstants.FACET_CONFIRMATION + "' is not supported for "
              + "this type of button. id = '"
              + component.getClientId(facesContext) + "'");
View Full Code Here

    }
    if (!(component instanceof ValueHolder)) {
      // TODO Message resource i18n
      throw new JspException("Component " + component.getClass().getName() + " is not instanceof ValueHolder");
    }
    ValueHolder valueHolder = (ValueHolder) component;

    Converter converter = null;

    if (isBindingSet() && !isBindingLiteral()) {
      Object valueBinding = getBindingAsBindingOrExpression();
      if (valueBinding != null) {
        Object obj = FacesUtils.getValueFromBindingOrExpression(valueBinding);
        if (obj != null && obj instanceof Converter) {
          converter = (Converter) obj;
        }
      }
    }

    if (converter == null && isConverterIdSet()) {
      String localConverterId;
      // evaluate any VB expression that we were passed
      if (!isConverterIdLiteral()) {
        Object typeValueBinding = getConverterIdAsBindingOrExpression();
        localConverterId = (String) FacesUtils.getValueFromBindingOrExpression(typeValueBinding);
      } else {
        localConverterId = getConverterIdValue();
      }
      converter = FacesContext.getCurrentInstance().getApplication().createConverter(localConverterId);
      if (converter != null && isBindingSet()) {
        Object valueBinding = getBindingAsBindingOrExpression();
        FacesUtils.setValueOfBindingOrExpression(FacesContext.getCurrentInstance(), converter, valueBinding);
      }
    }
    if (converter != null) {
      if (!isBindingLiteral()) {
        FacesUtils.setValueOfBindingOrExpression(
            FacesContext.getCurrentInstance(), converter, component, Attributes.CONVERTER);
      } else {
        valueHolder.setConverter(converter);
      }
    }
    // TODO else LOG.warn?
    return (SKIP_BODY);
  }
View Full Code Here

  public void apply(FaceletContext faceletContext, UIComponent parent)
      throws IOException, FacesException, ELException {
    if (parent instanceof ValueHolder) {
      if (ComponentSupport.isNew(parent)) {
        ValueHolder valueHolder = (ValueHolder) parent;
        Converter converter = null;
        ValueExpression valueExpression = null;
        if (binding != null) {
          valueExpression = binding.getValueExpression(faceletContext, Converter.class);
          converter = (Converter) valueExpression.getValue(faceletContext);
        }
        if (converter == null) {
          try {
            converter = FacesContext.getCurrentInstance().getApplication().createConverter(
                (String) converterId.getValueExpression(faceletContext, String.class).getValue(faceletContext));
          } catch (Exception e) {
            throw new TagAttributeException(tag, converterId, e.getCause());
          }
          if (valueExpression != null) {
            valueExpression.setValue(faceletContext, converter);
          }
        }
        if (converter != null) {
          valueHolder.setConverter(converter);
        }
        // TODO else LOG.warn?
      }
    } else {
      throw new TagException(tag, "Parent is not of type ValueHolder, type is: " + parent);
View Full Code Here

TOP

Related Classes of javax.faces.component.ValueHolder

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.