[seam-commits] Seam SVN: r9132 - trunk/src/main/org/jboss/seam/framework.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Sep 24 03:43:04 EDT 2008


Author: dan.j.allen
Date: 2008-09-24 03:43:03 -0400 (Wed, 24 Sep 2008)
New Revision: 9132

Modified:
   trunk/src/main/org/jboss/seam/framework/Query.java
Log:
Add a convenience method to register restriction expression strings from Java
this conversion is handled automatically through component configuration


Modified: trunk/src/main/org/jboss/seam/framework/Query.java
===================================================================
--- trunk/src/main/org/jboss/seam/framework/Query.java	2008-09-24 05:49:02 UTC (rev 9131)
+++ trunk/src/main/org/jboss/seam/framework/Query.java	2008-09-24 07:43:03 UTC (rev 9132)
@@ -10,6 +10,7 @@
 
 import org.jboss.seam.annotations.Create;
 import org.jboss.seam.annotations.Transactional;
+import org.jboss.seam.core.Expressions;
 import org.jboss.seam.core.Expressions.ValueExpression;
 import org.jboss.seam.faces.DataModels;
 import org.jboss.seam.persistence.QueryParser;
@@ -371,7 +372,31 @@
       refresh();
    }
 
+   /**
+    * A convenience method for registering the restrictions from Strings. This
+    * method is primarily intended to be used from Java, not to expose a bean
+    * property for component configuration. Use setRestrictions() for the later.
+    */
+   public void setRestrictionExpressionStrings(List<String> expressionStrings)
+   {
+      Expressions expressions = new Expressions();
+      List<ValueExpression> restrictionVEs = new ArrayList<ValueExpression>(expressionStrings.size());
+      for (String expressionString : expressionStrings)
+      {
+         restrictionVEs.add(expressions.createValueExpression(expressionString));
+      }
+      setRestrictions(restrictionVEs);
+   }
    
+   public List<String> getRestrictionExpressionStrings()
+   {
+      List<String> expressionStrings = new ArrayList<String>();
+      for (ValueExpression restriction : getRestrictions())
+      {
+         expressionStrings.add(restriction.getExpressionString());
+      }
+      return expressionStrings;
+   }
    
     public String getGroupBy() {
         return groupBy;




More information about the seam-commits mailing list