Author: abelevich
Date: 2008-01-10 09:53:18 -0500 (Thu, 10 Jan 2008)
New Revision: 5268
Modified:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
Log:
refactor getConvertedStringValue method
Modified:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
---
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10
14:33:35 UTC (rev 5267)
+++
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10
14:53:18 UTC (rev 5268)
@@ -155,16 +155,22 @@
protected String getConvertedStringValue(FacesContext context, UIComboBox comboBox,
Object value) {
Converter converter = comboBox.getConverter();
+
if (converter == null) {
if (value == null) {
return "";
} else if (value instanceof String) {
return (String) value;
- } else {
- String message = "Value is not String (class=" + value.getClass().getName()
+ ", value=" + value
- + ") and component " + comboBox.getClientId(context) + " does not
have a Converter";
- throw new IllegalArgumentException(message);
}
+
+ Class converterType = value.getClass();
+ if (converterType != null ) {
+ converter = context.getApplication().createConverter(converterType);
+ }
+
+ if (converter == null) {
+ return value.toString();
+ }
}
return converter.getAsString(context, comboBox, value);
}