public static Converter findUISelectManyConverter ( FacesContext facesContext , UISelectMany component , boolean considerValueType ) { // If the component has an attached Converter, use it. Converter converter = component . getConverter ( ) ; if ( converter != null ) { return converter ; } if ( considerValueType ) { // try to get a converter from the valueType attribute converter = _SharedRendererUtils . getValueTypeConverter ( facesContext , component ) ; if ( converter != null ) { return converter ; } } //Try to find out by value expression ValueExpression ve = component . getValueExpression ( "value" ) ; if ( ve == null ) { return null ; } // Try to get the type from the actual value or, // if value == null, obtain the type from the ValueExpression Class < ? > valueType = null ; Object value = ve . getValue ( facesContext . getELContext ( ) ) ; valueType = ( value != null ) ? value . getClass ( ) : ve . getType ( facesContext . getELContext ( ) ) ; if ( valueType == null ) { return null ; } // a valueType of Object is also permitted, in order to support // managed bean properties of type Object that resolve to null at this point if ( Collection . class . isAssignableFrom ( valueType ) || Object . class . equals ( valueType ) ) { // try to get the by-type-converter from the type of the SelectItems return _SharedRendererUtils . getSelectItemsValueConverter ( new SelectItemsIterator ( component , facesContext ) , facesContext ) ; } if ( ! valueType . isArray ( ) ) { throw new IllegalArgumentException ( "ValueExpression for UISelectMany : " + getPathToComponent ( component ) + " must be of type Collection or Array" ) ; } Class < ? > arrayComponentType = valueType . getComponentType ( ) ; if ( String . class . equals ( arrayComponentType ) ) { return null ; //No converter needed for String type } if ( Object . class . equals ( arrayComponentType ) ) { // There is no converter for Object class // try to get the by-type-converter from the type of the SelectItems return _SharedRendererUtils . getSelectItemsValueConverter ( new SelectItemsIterator ( component , facesContext ) , facesContext ) ; } try { return facesContext . getApplication ( ) . createConverter ( arrayComponentType ) ; } catch ( FacesException e ) { log . log ( Level . SEVERE , "No Converter for type " + arrayComponentType . getName ( ) + " found" , e ) ; return null ; } }
Find proper Converter for the entries in the associated Collection or array of the given UISelectMany as specified in API Doc of UISelectMany . If considerValueType is true the valueType attribute will be used in addition to the standard algorithm to get a valid converter .