[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...
Gavin King
gavin.king at jboss.com
Tue Jul 25 00:40:43 EDT 2006
User: gavin
Date: 06/07/25 00:40:43
Modified: src/main/org/jboss/seam Component.java
Log:
improvements to parameter handling and EL configuration
Revision Changes Path
1.150 +35 -11 jboss-seam/src/main/org/jboss/seam/Component.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Component.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/Component.java,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -b -r1.149 -r1.150
--- Component.java 24 Jul 2006 23:54:30 -0000 1.149
+++ Component.java 25 Jul 2006 04:40:42 -0000 1.150
@@ -80,6 +80,7 @@
import org.jboss.seam.util.Reflections;
import org.jboss.seam.util.SortItem;
import org.jboss.seam.util.SorterNew;
+import org.jboss.seam.util.Conversions.PropertyValue;
/**
* A Seam component is any POJO managed by Seam.
@@ -87,7 +88,7 @@
*
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @author Gavin King
- * @version $Revision: 1.149 $
+ * @version $Revision: 1.150 $
*/
@Scope(ScopeType.APPLICATION)
public class Component
@@ -323,12 +324,11 @@
//note that org.jboss.seam.core.init.jndiPattern looks like an EL expression but is not one!
if ( propertyValue.isExpression() && !beanClass.equals(Init.class) ) //TODO: support #{...} in <value> element
{
- return new ELInitialValue( propertyValue.getSingleValue() );
+ return new ELInitialValue(propertyValue, parameterClass, parameterType);
}
else
{
- Object value = Conversions.getConverter(parameterClass).toObject(propertyValue, parameterType);
- return new ConstantInitialValue(value);
+ return new ConstantInitialValue(propertyValue, parameterClass, parameterType);
}
}
@@ -1558,9 +1558,9 @@
{
private Object value;
- public ConstantInitialValue(Object value)
+ public ConstantInitialValue(PropertyValue propertyValue, Class parameterClass, Type parameterType)
{
- this.value = value;
+ this.value = Conversions.getConverter(parameterClass).toObject(propertyValue, parameterType);
}
public Object getValue(Class type)
@@ -1579,29 +1579,53 @@
{
private String expression;
//private ValueBinding vb;
+ private Conversions.Converter converter;
+ private Type parameterType;
- public ELInitialValue(String expression)
+ public ELInitialValue(PropertyValue propertyValue, Class parameterClass, Type parameterType)
{
- this.expression = expression;
+ this.expression = propertyValue.getSingleValue();
+ this.parameterType = parameterType;
+ try
+ {
+ this.converter = Conversions.getConverter(parameterClass);
+ }
+ catch (IllegalArgumentException iae) {
+ //no converter for the type
+ }
//vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(expression);
}
public Object getValue(Class type)
{
+ Object value;
if ( type.equals(ValueBinding.class) )
{
- return createValueBinding();
+ value = createValueBinding();
}
else
{
- return createValueBinding().getValue( FacesContext.getCurrentInstance() );
+ value = createValueBinding().getValue( FacesContext.getCurrentInstance() );
+ }
+
+ if (converter!=null && value instanceof String)
+ {
+ return converter.toObject( new Conversions.FlatPropertyValue( (String) value ), parameterType );
+ }
+ else if (converter!=null && value instanceof String[])
+ {
+ return converter.toObject( new Conversions.MultiPropertyValue( (String[]) value ), parameterType );
+ }
+ else
+ {
+ return value;
}
}
private ValueBinding createValueBinding()
{
return FacesContext.getCurrentInstance().getApplication()
- .createValueBinding(expression);
+ .createValueBinding( expression );
}
public String toString()
More information about the jboss-cvs-commits
mailing list