Package javax.faces.convert

Examples of javax.faces.convert.Converter


        if (submittedValue != null) {
            return submittedValue;
        }

        Object value = input.getValue();
        Converter converter = converterLookupStrategy.getConverterByValue(context, input, value);

        if (converter != null) {
            return converter.getAsString(context, input, value);
        } else {
            return value != null ? value.toString() : "";
        }
    }
View Full Code Here


    }

    private String getRowKeyAsString(FacesContext facesContext, Object rowKey) {
        assert rowKey != null;

        Converter rowKeyConverter = getRowKeyConverter();
        if (rowKeyConverter == null) {
            // Create default converter for a row key.
            rowKeyConverter = facesContext.getApplication().createConverter(rowKey.getClass());

            // Store converter for a invokeOnComponents call.
            if (rowKeyConverter != null) {
                // TODO - review
                setRowKeyConverter(rowKeyConverter);
            }
        }

        if (rowKeyConverter != null) {
            return rowKeyConverter.getAsString(facesContext, this, rowKey);
        } else {
            return rowKey.toString();
        }
    }
View Full Code Here

                // baseId.length() + 1 expression skips SEPARATOR_CHAR
                // TODO - convertKeyString
                String rowKeyString = extractKeySegment(context, clientId.substring(baseId.length() + 1));

                if (rowKeyString != null) {
                    Converter keyConverter = getRowKeyConverter();

                    if (null != keyConverter) {
                        try {
                            // TODO: review
                            newRowKey = keyConverter.getAsObject(context, this, rowKeyString);
                        } catch (ConverterException e) {

                            // TODO: LOG error
                        }
                    }
View Full Code Here

            }

            Object newRowKey = null;

            if (rowId != null) {
                Converter keyConverter = getRowKeyConverter();

                if (null != keyConverter) {
                    try {
                        newRowKey = keyConverter.getAsObject(context, this, rowId);
                    } catch (ConverterException e) {
                        LOG.warn(e);
                    }
                }
            }
View Full Code Here

            throw new FacesException("Could not find any registered converter-class by converterId : "+converterId);
        }

        try
        {
            final Converter converter = (Converter) converterClass.newInstance();

            setConverterProperties(converterClass, converter);

            return converter;
        }
View Full Code Here

            {
                for (int i = 0, len = interfaces.length; i < len; i++)
                {
                    // search all superinterfaces for a matching converter,
                    // create it
                    final Converter converter = internalCreateConverter(interfaces[i]);
                    if (converter != null)
                    {
                        return converter;
                    }
                }
            }
        }

        // Get EnumConverter for enum classes with no special converter, check
        // here as recursive call with java.lang.Enum will not work
        if (converterClassName == null && targetClass.isEnum()) {
            converterClassName = _converterClassNameToClassMap.get(Enum.class);
        }

        if (converterClassName != null)
        {
            try
            {
                Class<? extends Converter> converterClass = ClassUtils.simpleClassForName(converterClassName);
                Converter converter = null;

                // check cached constructor information
                if (!_noArgConstructorConverterClasses.contains(converterClass))
                {
                    // the converter class either supports the one-arg constructor
View Full Code Here

            try
            {

               // get the type of the referenced property and try to obtain a converter for it
               Class<?> expectedType = elUtils.getExpectedType(context, el);
               Converter converter = context.getApplication().createConverter(expectedType);

               // Use the convert to create the correct type
               if (converter != null)
               {
                  Object convertedValue = converter.getAsObject(context, new NullComponent(), valueAsString);
                  elUtils.setValue(context, el, convertedValue);
               }
               else
               {
                  elUtils.setValue(context, el, valueAsString);
View Full Code Here

                     String valueAsString = queryString.getParameter(name);

                     // get the type of the referenced property and try to obtain a converter for it
                     Class<?> expectedType = elUtils.getExpectedType(context, el);
                     Converter converter = context.getApplication().createConverter(expectedType);

                     // Use the convert to create the correct type
                     if (converter != null)
                     {
                        Object convertedValue = converter.getAsObject(context, new NullComponent(), valueAsString);
                        elUtils.setValue(context, el, convertedValue);
                     }
                     else
                     {
                        elUtils.setValue(context, el, valueAsString);
View Full Code Here

               throw new PrettyException("PrettyFaces: Exception occurred while building URL for MappingId < "
                        + mapping.getId() + " >, Required value " + " < " + expression + " > was null");
            }

            // convert the value to a string using the correct converter
            Converter converter = context.getApplication().createConverter(value.getClass());
            if (converter != null)
            {
               String convertedValue = converter.getAsString(context, new NullComponent(), value);
               if (convertedValue == null)
               {
                  throw new PrettyException("PrettyFaces: The converter <" + converter.getClass().getName()
                           + "> returned null while converting the object <" + value.toString() + ">!");
               }
               value = convertedValue;
            }
View Full Code Here

    if (!(component instanceof ValueHolder)) {
      return currentValue.toString();
    }

    Converter converter = ((ValueHolder) component).getConverter();

    if (converter == null) {
      if (currentValue instanceof String) {
        return (String) currentValue;
      }
      Class converterType = currentValue.getClass();
      converter = context.getApplication().createConverter(converterType);
    }

    if (converter == null) {
      return currentValue.toString();
    } else {
      return converter.getAsString(context, component, currentValue);
    }
  }
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.