On one of my first reads of the Web Beans spec, I had this vision of being
able to bind a method with arguments to a UI interface component and then
have Web Beans inject the parameters at invocation time. This would give
dependency injection that is isolated to the method call (and contextual).
<h:commandButton action="#{hotelSearch.find}" value="Search"/>
public void find(@Current SearchCriteria searchCriteria) {
...
}
However, once again we get stumped by the EL. The EL is going to look for a
method with no arguments or, as of EL 1.2, an argument count matching the
parameterized EL expression. What I would like is for the EL to locate a
method with the same name with 0 or more arguments where every argument can
be satisfied by Web Beans. Naturally, overloading would not be allowed since
it would introduce ambiguity. So you could have exactly one method like this
to be used as an alternative to a no-args method (the restriction would be
per method name of course).
The downside of doing #{hotelSearch.find(searchCriteria)} is that you have
to name (i.e., @Named) all possible arguments and you can't leverage binding
annotations (everything is name based).
We could do something like this in Seam 3, taking over the torch from Seam 2
that made Faces event arguments optional.
Thoughts?
-Dan
--
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://in.relation.to/Bloggers/Dan
NOTE: While I make a strong effort to keep up with my email on a daily
basis, personal or other work matters can sometimes keep me away
from my email. If you contact me, but don't hear back for more than a week,
it is very likely that I am excessively backlogged or the message was
caught in the spam filters. Please don't hesitate to resend a message if
you feel that it did not reach my attention.