Package javax.faces.component

Examples of javax.faces.component.ValueHolder


  }

  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


    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

    }

    public void apply(FaceletContext context, UIComponent uiComponent) throws IOException, FacesException, ELException {
        if (!(uiComponent instanceof ValueHolder))
            return;
        ValueHolder fake = (ValueHolder) uiComponent;
        fake.setValue(value);
    }
View Full Code Here

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

* @author Natalia.Zolochevska@Teamdev.com
*/
public class ValueHolderDataExtractor implements ComponentDataExtractor {

    public Object getData(UIComponent component) {
        ValueHolder valueHolder = (ValueHolder) component;
        FacesContext context = FacesContext.getCurrentInstance();
        Object value = valueHolder.getValue();
        Converter valueConverter = valueHolder.getConverter();
        if (valueConverter != null) {
            return valueConverter.getAsString(context, component, value);
        }
        return value;
    }
View Full Code Here

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

            Manager.instance().beforeRedirect();
        } else {
            UIComponent parent = getParent();

            if (parent instanceof ValueHolder) {
                ValueHolder holder = (ValueHolder) parent;
                holder.setValue(documentData);
            }

        }
    }
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)
               {
                  Converter converter = facesContext.getApplication().createConverter(
                           valueExpression.getType(facesContext.getELContext()));
                  if (converter != null)
                  {
                     addConverterToChain(converter);
                  }
               }
            }
            valueHolder.setConverter(this);
         }
      }
   }
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

    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

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.