Package javax.faces.component

Examples of javax.faces.component.ValueHolder


        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


    }
    return onclick;
  }

  private String appendConfirmationScript(String onclick, UIComponent component) {
    ValueHolder confirmation = (ValueHolder) component.getFacet(FACET_CONFIRMATION);
    if (confirmation != null) {
      StringBuilder script = new StringBuilder();
      script.append("return confirm('");
      script.append(confirmation.getValue());
      script.append("')");
      if (onclick != null) {
        script.append(" && ");
        script.append(onclick);
      }
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;
  }

  private String appendConfirmationScript(String onclick, UIComponent component) {
    ValueHolder confirmation = (ValueHolder) component.getFacet(FACET_CONFIRMATION);
    if (confirmation != null) {
      StringBuilder script = new StringBuilder();
      script.append("return confirm('");
      script.append(confirmation.getValue());
      script.append("')");
      if (onclick != null) {
        script.append(" && ");
        script.append(onclick);
      }
View Full Code Here

      this.omit = Boolean.TRUE;
    }
  }

  private static String getConfirmation(final AbstractUICommandBase command) {
    final ValueHolder facet = (ValueHolder) command.getFacet(Facets.CONFIRMATION);
    return facet != null ? "" + facet.getValue() : null;
  }
View Full Code Here

   public ConverterChain(UIComponent component)
   {
      this();
      if (component instanceof ValueHolder)
      {
         ValueHolder valueHolder = (ValueHolder) component;
         if (!(valueHolder.getConverter() instanceof ConverterChain))
         {
            ValueExpression converterValueExpression = component.getValueExpression("converter");
            if (converterValueExpression != null)
            {
               addConverterToChain(converterValueExpression);
            }
            else if (valueHolder.getConverter() != null)
            {
               addConverterToChain(valueHolder.getConverter());
            }
            else
            {
               ValueExpression valueExpression = component.getValueExpression("value");
               FacesContext facesContext = FacesContext.getCurrentInstance();
               if (valueExpression != null)
               {
                  Class<?> type = valueExpression.getType(facesContext.getELContext());
                  if (type != null)
                  {
                     Converter converter = facesContext.getApplication().createConverter(type);
                     if (converter != null)
                     {
                        addConverterToChain(converter);
                     }
                  }
               }
            }
            valueHolder.setConverter(this);
         }
      }
   }
View Full Code Here

  }

  protected void setConverterProperty(UIComponent component, ValueExpression converter) {
        if (converter != null) {
      if (component instanceof ValueHolder) {
        ValueHolder output = (ValueHolder) component;
                if (!converter.isLiteralText()) {
                    component.setValueExpression("converter", converter);
                } else {
                    Converter conv = FacesContext.getCurrentInstance().getApplication().createConverter(converter.getExpressionString());
                    output.setConverter(conv);
                }
      } else {
         throw new IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR, component.getClass().getName()));
      }
        }
View Full Code Here

   private Object getParentValue()
   {
      if (getParent() instanceof ValueHolder)
      {
         ValueHolder parent = (ValueHolder) getParent();
         return parent.getValue();
      }
      else
      {
         return null;
      }
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

      {
        // 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

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.