[jboss-cvs] jboss-seam/src/main/org/jboss/seam ...

Gavin King gavin.king at jboss.com
Sun Jan 28 14:12:04 EST 2007


  User: gavin   
  Date: 07/01/28 14:12:04

  Modified:    src/main/org/jboss/seam  Component.java
  Log:
  make EL work in list <value> JBSEAM-707
  
  Revision  Changes    Path
  1.224     +47 -1     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.223
  retrieving revision 1.224
  diff -u -b -r1.223 -r1.224
  --- Component.java	18 Dec 2006 15:38:48 -0000	1.223
  +++ Component.java	28 Jan 2007 19:12:04 -0000	1.224
  @@ -122,7 +122,7 @@
    *
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
    * @author Gavin King
  - * @version $Revision: 1.223 $
  + * @version $Revision: 1.224 $
    */
   @Scope(ScopeType.APPLICATION)
   @SuppressWarnings("deprecation")
  @@ -396,6 +396,10 @@
         {
            return new ELInitialValue(propertyValue, parameterClass, parameterType);
         }
  +      else if ( propertyValue.isMultiValued() )
  +      {
  +         return new ListInitialValue(propertyValue, parameterClass, parameterType);
  +      }
         else
         {
            return new ConstantInitialValue(propertyValue, parameterClass, parameterType);
  @@ -2059,6 +2063,48 @@
   
      }
   
  +   public static class ListInitialValue implements InitialValue
  +   {
  +      private InitialValue[] initialValues;
  +      private Class elementType;
  +
  +      public ListInitialValue(PropertyValue propertyValue, Class collectionClass, Type collectionType)
  +      {
  +         String[] expressions = propertyValue.getMultiValues();
  +         this.initialValues = new InitialValue[expressions.length];
  +         elementType = Reflections.getCollectionElementType(collectionType);
  +         for ( int i=0; i<expressions.length; i++ )
  +         {
  +            PropertyValue elementValue = new Conversions.FlatPropertyValue( expressions[i] );
  +            if ( elementValue.isExpression() )
  +            {
  +               initialValues[i] = new ELInitialValue(elementValue, elementType, elementType);
  +            }
  +            else
  +            {
  +               initialValues[i] = new ConstantInitialValue(elementValue, elementType, elementType);
  +            }
  +         }
  +      }
  +
  +      public Object getValue(Class type)
  +      {
  +         List result = new ArrayList(initialValues.length);
  +         for (InitialValue iv: initialValues)
  +         {
  +            result.add( iv.getValue(elementType) );
  +         }
  +         return result;
  +      }
  +      
  +      @Override
  +      public String toString()
  +      {
  +         return "ListInitialValue(" + elementType.getSimpleName() + ")";
  +      }
  +
  +   }
  +   
      public Method getPostActivateMethod()
      {
         return postActivateMethod;
  
  
  



More information about the jboss-cvs-commits mailing list