Author: amarkhel
Date: 2010-11-01 11:37:39 -0400 (Mon, 01 Nov 2010)
New Revision: 19843
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java
Log:
in case of RF-9595 - this is not good to throw ConverterException when converter not
found, 'getConverterForProperty' method is depricated
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java
===================================================================
---
trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java 2010-11-01
15:32:23 UTC (rev 19842)
+++
trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java 2010-11-01
15:37:39 UTC (rev 19843)
@@ -280,7 +280,10 @@
* @param component
* @param property
* @return converter for specified component attribute
+ * @deprecated use SelectUtils.findConverter instead
*/
+
+ @Deprecated
public static Converter getConverterForProperty(FacesContext facesContext, UIOutput
component, String property) {
Converter converter = component.getConverter();
@@ -306,4 +309,27 @@
return converter;
}
+
+ public static Converter findConverter(FacesContext facesContext, UIOutput component,
String property) {
+ Converter converter = component.getConverter();
+
+ if (converter == null) {
+
+ ValueExpression ve = component.getValueExpression(property);
+
+ if (ve != null) {
+
+ Class<?> valueType = ve.getType(facesContext.getELContext());
+ if ((valueType == null) || String.class.equals(valueType) ||
Object.class.equals(valueType)) {
+ // No converter needed
+ } else {
+ converter =
facesContext.getApplication().createConverter(valueType);
+ }
+
+ }
+ }
+
+ return converter;
+ }
+
}