Package javax.faces.convert

Examples of javax.faces.convert.Converter


   /**
    * Convert the string value of a page parameter to the required type
    */
   public Object convertValueFromString(FacesContext facesContext, String value)
   {
      Converter converter = null;
      try
      {
         converter = getConverter();
      }
      catch (RuntimeException re)
      {
         //YUCK! due to bad JSF/MyFaces error handling
         log.warn("could not create converter for: " + name, re);
         return null;
      }
     
      return converter==null ?
            value :
            converter.getAsObject( facesContext, facesContext.getViewRoot(), value );
   }
View Full Code Here


    // TODO make this a property of model

    @Override
    @Attribute
    public Converter getRowKeyConverter() {
        Converter converter = super.getRowKeyConverter();

        if (converter == null) {
            if (defaultRowKeyConverter == null) {
                defaultRowKeyConverter = getFacesContext().getApplication().createConverter(Integer.class);
            }
View Full Code Here

            Object convertedValue = requestValue;

            if (requestValue != null) {
                Class<?> type = updateBinding.getType(elContext);
                Converter converter = createConverter(context, type);

                if (null != converter) {
                    convertedValue = converter.getAsObject(context, this, requestValue);
                }
            }

            if (null != convertedValue) {
                updateBinding.setValue(elContext, convertedValue);
View Full Code Here

        // TODO - perform conversion if converter is present.
        if (null != value) {
            Class<?> type = value.getClass();
            FacesContext context = getFacesContext();
            Converter converter = createConverter(context, type);

            if (null != converter) {
                value = converter.getAsString(context, this, value);
            }
        }

        return value;
    }
View Full Code Here

     * @param type Type of class
     * @return converter
     * @throws FacesException if something goes wrong
     */
    private Converter createConverter(FacesContext context, Class<?> type) throws FacesException {
        Converter converter = getConverter();

        if (converter == null && type != null && !type.equals(String.class) && !type.equals(Object.class)) {
            try {
                converter = context.getApplication().createConverter(type);
            } catch (Exception e) {
View Full Code Here

    @Override
    public void markInitialState() {
        super.markInitialState();

        Converter c = getConverter();
        if (c instanceof PartialStateHolder) {
            ((PartialStateHolder) c).markInitialState();
        }
    }
View Full Code Here

    @Override
    public void clearInitialState() {
        if (initialStateMarked()) {
            super.clearInitialState();

            Converter c = getConverter();
            if (c instanceof PartialStateHolder) {
                ((PartialStateHolder) c).clearInitialState();
            }
        }
    }
View Full Code Here

    }

    public static String getConvertedStringValue(FacesContext context, UIComponent component,
        ConverterLookupStrategy converterLookupStrategy, Object value) throws ConverterException {

        Converter converter = converterLookupStrategy.getConverterByValue(context, component, value);
        if (converter != null) {
            return converter.getAsString(context, component, value);
        }

        if (value == null) {
            return "";
        }
View Full Code Here

     * <p>Returns {@link Converter} based on a converter configured for provided {@link UIComponent} or returns converter for type referenced by given property's {@link ValueExpression}.</p>
     *
     * <p>If no converter applied for conditions above, null is returned instead.</p>
     */
    public static Converter findConverter(FacesContext facesContext, UIComponent component, String property) {
        Converter converter = null;

        if (component instanceof ValueHolder) {
            converter = ((ValueHolder) component).getConverter();
        }

View Full Code Here

        String submittedString = (String) val;
        if (Strings.isNullOrEmpty(submittedString)) {
            return null;
        }

        Converter converter = converterLookupStrategy.getConverterByProperty(context, (UIInput) component);
        if (converter != null) {
            return converter.getAsObject(context, component, submittedString);
        }

        return submittedString;
    }
View Full Code Here

TOP

Related Classes of javax.faces.convert.Converter

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.