Author: Alex.Kolonitsky
Date: 2009-07-30 08:11:14 -0400 (Thu, 30 Jul 2009)
New Revision: 15064
Modified:
branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java
Log:
PickList: converterMessage attribute does not work.
https://jira.jboss.org/jira/browse/RF-7495
Modified:
branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java
===================================================================
---
branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java 2009-07-30
12:08:33 UTC (rev 15063)
+++
branches/community/3.3.X/framework/impl/src/main/java/org/ajax4jsf/util/SelectUtils.java 2009-07-30
12:11:14 UTC (rev 15064)
@@ -34,6 +34,7 @@
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.UIOutput;
@@ -180,8 +181,7 @@
arrayComponentType == null ? Object.class
: arrayComponentType, len);
for (int i = 0; i < len; i++) {
- convertedValues[i] = converter.getAsObject(facesContext,
- component, submittedValue[i]);
+ convertedValues[i] = getConvertedValue(facesContext, component, submittedValue[i],
converter);
}
return convertedValues;
}
@@ -196,8 +196,10 @@
int len = submittedValue.length;
List<Object> lst = new ArrayList<Object>(len);
for (int i = 0; i < len; i++) {
- lst.add(converter.getAsObject(facesContext, component,
- submittedValue[i]));
+ Object convertedValue = getConvertedValue(facesContext, component, submittedValue[i],
converter);
+ if (convertedValue != null) {
+ lst.add(convertedValue);
+ }
}
return lst;
}
@@ -211,8 +213,10 @@
int len = submittedValue.length;
Object convertedValues = Array.newInstance(arrayComponentType, len);
for (int i = 0; i < len; i++) {
- Array.set(convertedValues, i, converter.getAsObject(
- facesContext, component, submittedValue[i]));
+ Object convertedValue = getConvertedValue(facesContext, component, submittedValue[i],
converter);
+ if (convertedValue != null) {
+ Array.set(convertedValues, i, convertedValue);
+ }
}
return convertedValues;
} else {
@@ -220,14 +224,38 @@
int len = submittedValue.length;
ArrayList<Object> convertedValues = new ArrayList<Object>(len);
for (int i = 0; i < len; i++) {
- convertedValues.add(i, converter.getAsObject(facesContext,
- component, submittedValue[i]));
+ Object convertedValue = getConvertedValue(facesContext, component, submittedValue[i],
converter);
+ if (convertedValue != null) {
+ convertedValues.add(i, convertedValue);
+ }
}
return convertedValues.toArray((Object[]) Array.newInstance(
arrayComponentType, len));
}
}
+ private static Object getConvertedValue(FacesContext context,
+ UISelectMany component, String submittedValue, Converter converter) {
+ try {
+ return converter.getAsObject(context, component, submittedValue);
+ } catch (ConverterException e) {
+ addConversionErrorMessage(context, component.getClientId(context),
+ component.getConverterMessage());
+ }
+ return null;
+ }
+
+ private static void addConversionErrorMessage(FacesContext context,
+ String clientId, String converterMessage) {
+
+ if (converterMessage == null) {
+ return;
+ }
+
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
converterMessage, converterMessage);
+ context.addMessage(clientId, message);
+ }
+
public static Object getConvertedUIInputValue(
FacesContext facesContext, UIInput component,
String submittedValue) throws ConverterException{