Author: nbelaevski
Date: 2008-12-03 17:29:10 -0500 (Wed, 03 Dec 2008)
New Revision: 11535
Removed:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
Log:
RF-4540
Modified: trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2008-12-03
18:59:50 UTC (rev 11534)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2008-12-03
22:29:10 UTC (rev 11535)
@@ -36,6 +36,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.el.ELContextWrapper;
import org.hibernate.validator.ClassValidator;
import org.hibernate.validator.InvalidValue;
Deleted:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java 2008-12-03
18:59:50 UTC (rev 11534)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java 2008-12-03
22:29:10 UTC (rev 11535)
@@ -1,98 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.validator;
-
-import java.util.Locale;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.FunctionMapper;
-import javax.el.VariableMapper;
-
-/**
- * @author asmirnov
- *
- */
-public class ELContextWrapper extends ELContext {
-
- private final ELContext parent;
-
- private final ELResolver resolver;
-
- /**
- * @param parent
- */
- public ELContextWrapper(ELContext parent,ELResolver resolver) {
- super();
- this.resolver = resolver;
- this.parent = parent;
- }
-
- /* (non-Javadoc)
- * @see javax.el.ELContext#getELResolver()
- */
- @Override
- public ELResolver getELResolver() {
- return resolver;
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getFunctionMapper()
- */
- public FunctionMapper getFunctionMapper() {
- return parent.getFunctionMapper();
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getVariableMapper()
- */
- public VariableMapper getVariableMapper() {
- return parent.getVariableMapper();
- }
-
- /**
- * @param key
- * @return
- * @see javax.el.ELContext#getContext(java.lang.Class)
- */
- public Object getContext(Class key) {
- return parent.getContext(key);
- }
-
- /**
- * @param key
- * @param contextObject
- * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
- */
- public void putContext(Class key, Object contextObject) {
- parent.putContext(key, contextObject);
- }
-
- public Locale getLocale() {
- return parent.getLocale();
- }
-
- public void setLocale(Locale locale) {
- parent.setLocale(locale);
- }
-}
Modified: trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
---
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-12-03
18:59:50 UTC (rev 11534)
+++
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-12-03
22:29:10 UTC (rev 11535)
@@ -30,6 +30,7 @@
import java.util.Set;
import java.util.Map.Entry;
+import javax.el.ValueExpression;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
@@ -793,6 +794,15 @@
return super.getValueBinding(name);
}
+ @Override
+ public ValueExpression getValueExpression(String name) {
+ if ("value".equals(name)) {
+ return super.getValueExpression("sourceValue");
+ }
+
+ return super.getValueExpression(name);
+ }
+
public void setValue(Object value) {
this.valueHolder = (ValueHolder) value;
}
Modified:
trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
===================================================================
---
trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2008-12-03
18:59:50 UTC (rev 11534)
+++
trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2008-12-03
22:29:10 UTC (rev 11535)
@@ -113,7 +113,7 @@
ResponseWriter writer = context.getResponseWriter();
StringWriter stringWriter = new StringWriter();
context.setResponseWriter(writer.cloneWithWriter(stringWriter));
- encodeRows(context, shuttle, new ListShuttleRendererTableHolder(shuttle,
getConverter(context, shuttle), source));
+ encodeRows(context, shuttle, new ListShuttleRendererTableHolder(shuttle,
getConverter(context, shuttle, true), source));
context.getResponseWriter().flush();
context.setResponseWriter(writer);
@@ -322,7 +322,7 @@
boolean facadeSource = true;
- Converter converter = getConverter(context, listShuttle);
+ Converter converter = getConverter(context, listShuttle, false);
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
Modified:
trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
===================================================================
---
trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2008-12-03
18:59:50 UTC (rev 11534)
+++
trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2008-12-03
22:29:10 UTC (rev 11535)
@@ -20,6 +20,7 @@
*/
package org.richfaces.component;
+import java.beans.FeatureDescriptor;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
@@ -29,6 +30,9 @@
import java.util.List;
import java.util.Map;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
@@ -41,7 +45,6 @@
import javax.faces.convert.ConverterException;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
import javax.faces.model.ArrayDataModel;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
@@ -51,6 +54,7 @@
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.RepeatState;
+import org.ajax4jsf.util.ELUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.EmptyIterator;
import org.apache.commons.collections.iterators.FilterIterator;
@@ -584,21 +588,27 @@
return null;
}
+ private static final Converter noOpConverter = new Converter() {
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+ return value;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ return (String) value;
+ }
+ };
+
public Converter getConverterForValue(FacesContext context) {
- ValueBinding binding = this.getValueBinding("value");
- if (binding != null) {
- Class type = binding.getType(context);
- if (type != null) {
- Class componentType = type.getComponentType();
- if (componentType != null) {
- return getConverterForType(context, componentType);
- } else {
- //support for generics introspection
- }
- }
+ ValueExpression expression = this.getValueExpression("value");
+ Class<?> containerClass = ELUtils.getContainerClass(context, expression);
+
+ Converter converter = getConverterForType(context, containerClass);
+ if (converter == null && String.class.equals(containerClass)) {
+ converter = noOpConverter;
}
- return null;
+ return converter;
}
-
-}
+}
\ No newline at end of file
Modified:
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
---
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-12-03
18:59:50 UTC (rev 11534)
+++
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-12-03
22:29:10 UTC (rev 11535)
@@ -45,6 +45,7 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIOrderingBaseComponent;
import org.richfaces.component.UIOrderingBaseComponent.ItemState;
+import org.richfaces.component.util.MessageUtil;
/**
* @author Nick Belaevski
@@ -566,7 +567,7 @@
}
protected Converter getConverter(FacesContext context,
- UIOrderingBaseComponent component) {
+ UIOrderingBaseComponent component, boolean warnOnDefaultConverter) {
Converter converter = component.getConverter();
if (converter == null) {
@@ -575,6 +576,13 @@
if (converter == null) {
converter = DEFAULT_CONVERTER;
+
+ if (warnOnDefaultConverter) {
+ Object componentLabel = MessageUtil.getLabel(context, component);
+ context.getExternalContext().log("Converter for component [" +
componentLabel +
+ "] cannot be discovered, so default implementation of converter will be
used." +
+ " Component items will be converted to String on decoding.");
+ }
}
return converter;
Modified:
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
---
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2008-12-03
18:59:50 UTC (rev 11534)
+++
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2008-12-03
22:29:10 UTC (rev 11535)
@@ -128,8 +128,10 @@
public void encodeRows(FacesContext context, UIComponent component)
throws IOException {
- super.encodeRows(context, component, new
OrderingListRendererTableHolder((UIDataAdaptor) component,
- getConverter(context, (UIOrderingBaseComponent) component)));
+ UIOrderingBaseComponent orderingBaseComponent = (UIOrderingBaseComponent) component;
+
+ super.encodeRows(context, component, new
OrderingListRendererTableHolder(orderingBaseComponent,
+ getConverter(context, orderingBaseComponent, true)));
}
public void encodeOneRow(FacesContext context, TableHolder holder)
@@ -255,7 +257,7 @@
Object activeItem = null;
String[] strings = (String[])
externalContext.getRequestParameterValuesMap().get(clientId);
Map map = new LinkedHashMap();
- Converter converter = getConverter(context, orderingList);
+ Converter converter = getConverter(context, orderingList, false);
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
int idx = string.indexOf(':');