Package javax.faces.component

Examples of javax.faces.component.ValueHolder


    }
    return onclick;
  }

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

    final FacesContext facesContext = FacesContext.getCurrentInstance();
    final ELContext elContext = facesContext.getELContext();

    if (binding != null && !binding.isLiteralText()) {
      converter = (Converter) binding.getValue(elContext);
    }

    if (converter == null && converterId != null) {
      String localConverterId = (String) converterId.getValue(elContext);
      // evaluate any VB expression that we were passed
      converter = facesContext.getApplication().createConverter(localConverterId);
    }

    if (converter != null) {
      if (!binding.isLiteralText()) {
        ValueExpression ve = component.getValueExpression(Attributes.CONVERTER);
        if (ve != null) {
          ve.setValue(elContext, converter);
        }
      } else {
        valueHolder.setConverter(converter);
      }
    }

    return (SKIP_BODY);
  }
View Full Code Here

      this.omit = Boolean.TRUE;
    }
  }

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

  public void apply(FaceletContext faceletContext, UIComponent parent)
      throws IOException, FacesException, ELException {
    if (parent instanceof ValueHolder) {
      if (ComponentHandler.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

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

    }
   
    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

     
      String clientID = facetOrChild.getClientId(facesContext);
      if (uiDataMap.containsKey(clientID)) return; // optimization
     
      //System.out.println("**** Adding " + clientID + " to UIDataMap");
      ValueHolder valueHolder = (ValueHolder)facetOrChild;
      this.uiDataMap.put(clientID,
                         new UIDataValueManager(uiData, valueHolder));
      //System.out.println("****");
   }
View Full Code Here

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

        }

        // only process if it's been created
        if (parent.getParent() == null) {
            // cast to a ValueHolder
            ValueHolder vh = (ValueHolder) parent;
            ValueExpression ve = null;
            Converter c = null;
            if (this.binding != null) {
                ve = this.binding.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(this.tag, "No Converter was created");
            }
            this.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

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.