package jamaica.faces.novdl;

import static jamaica.faces.novdl.is_el.is_el;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.el.ELContext;
import javax.el.ExpressionFactory;

public class set_value_expression {
  
    /**
     * Set a value expression for a component property using the given 
     * EL expression.
     */
    public static void set_value_expression(FacesContext faces, 
                UIComponent component, String property, String expression) {
        if (!is_el(expression)) {
            throw new IllegalArgumentException("expression is not valid EL");
        } else {
            ELContext context = faces.getELContext();
            ExpressionFactory ex = faces.getApplication().getExpressionFactory();
            component.setValueExpression(property, 
                    ex.createValueExpression(context, expression, Object.class));
        }
    }
}

@@ -70,16 +70,111 @@
 .is_el;%0A
+import javax.el.ELContext;%0Aimport javax.el.ExpressionFactory;%0Aimport javax.el.ValueExpression;%0A
 import j
@@ -251,70 +251,8 @@
 ext;
-%0Aimport javax.el.ELContext;%0Aimport javax.el.ExpressionFactory;
 %0A%0Apu
@@ -420,12 +420,23 @@
 tic 
-void
+ValueExpression
  set
@@ -746,16 +746,21 @@
         
+Value
 Expressi
@@ -761,23 +761,16 @@
 pression
-Factory
  ex = fa
@@ -812,18 +812,22 @@
 actory()
-;
 %0A
+     
         
@@ -834,21 +834,18 @@
     
-component.set
+   .create
 Valu
@@ -860,99 +860,121 @@
 ion(
-property, %0A                    ex.createValueExpression(context, expression, Object.class))
+context, expression, Object.class);%0A            component.setValueExpression(property, ex);%0A            return ex
 ;%0A  

return ValueExpression from set_value_expression