-
1. Re: Dynamic expression evaluation
norman Mar 24, 2009 8:10 PM (in response to stephanos)Absolutely. In fact, it's something I've thought we should add to the debug page for some time.
-
2. Re: Dynamic expression evaluation
stephanos Mar 25, 2009 12:55 PM (in response to stephanos)Do you have an idea how to actually build it?
I've got no clue how to make Seam/JSF do it... -
3. Re: Dynamic expression evaluation
barakka Mar 25, 2009 1:13 PM (in response to stephanos)Hi,
i guess you can use the Expressions.instance().createValueExpression(String) method to create the EL expressions to get values of component properties and the createMethodExpression(String) for calling components methods. I've no idea, however, if these would work over any scoped object or only seam component.
Otherwise, you'll have to look into the javax.el package to create dynamically el expression (and check how seam gets the current EL context - the Expressions class contains methods to do just that).
Hope this help,
Riccardo. -
4. Re: Dynamic expression evaluation
stephanos Mar 25, 2009 3:48 PM (in response to stephanos)Thanks for the tip!
I managed to get a trivial example execute successfully:
@Name("actionEL") public class ActionEL { @In(required = false) private String dynamicEL; public void invoke () { Expressions expressions = Expressions.instance (); Expressions.MethodExpression<Object> el = expressions.createMethodExpression (dynamicEL); el.invoke (); } }
In the UI I got a simply input and command control:
<h:form> <h:inputText value="#{dynamicEL}"/> <h:commandButton value="Invoke" action="#{actionEL.invoke}" /> </h:form>
I tried entering #{identity.login} and magically the login was triggered :-)
-
5. Re: Dynamic expression evaluation
norman Mar 25, 2009 7:38 PM (in response to stephanos)That's really all there is to it. I also often use a similar strategy for testing ejbql queries, though I admit that if I actually learned how to use an IDE, I'm sure the hibernate tools could do that out of the box.