Dependent on the acceptance of the implementation for SWF-287 (EL support in spring-binding), I have created JIRA issue [SWF-301] for making JSF managed beans accessible to the flow definition via EL expressions. I have attached an initial patch for the implementation:
http://opensource.atlassian.com/proj...browse/SWF-301
With EL support in place, only some small additions to the FlowPhaseListener were required to merge JSF's configured resolvers into the ELExpressionParser's ELContext. To support JSF 1.1, I've taken the same approach as Facelets in using an adapter (ELResolverAdapter) to make the Variable/PropertyResolvers usable in the ELContext.
To demonstrate the use of this, I have included a JSF version of the number guess example application. Of particular interest is the mastermind flow, where the OGNL version of the flow:
has now become:Code:<action-state id="makeGuess"> <evaluate-action expression="flowScope.game.makeGuess(requestParameters.guess)"> <evaluation-result name="guessResult"/> </evaluate-action> <transition on="CORRECT" to="showAnswer"/> <transition on="*" to="enterGuess"/> </action-state>
where "game" refers to a JSF-managed request-scoped bean that is getting a flow-scoped model object injected into it via JSF's managed-property mechanism.Code:<action-state id="makeGuess"> <evaluate-action expression="game.makeGuess(game.guess)"> <evaluation-result name="guessResult"/> </evaluate-action> <transition on="CORRECT" to="showAnswer"/> <transition on="*" to="enterGuess"/> </action-state>
Also included is a series of unit tests that, aside from exercising the new functionality, prove the ability to still test this sort of flow outside of the container by making use of Shale's mock JSF library (or any other mock JSF library such as that from the jsf-extensions project or the one from Apache Trinidad).
I think this addition can go a long way in making SWF a more natural fit into a JSF application, completely eliminating the need to write intermediary actions and other sorts of glue code that expose JSF managed beans to the flow definition as some users are having to do right now. Once it is combined with being able to define Spring-managed beans with SWF custom scopes, defining all managed beans in the Spring application context becomes a much more natural proposition for SWF-JSF users.
As always, any feedback on this proposition is welcome and appreciated.
-Jeremy


Reply With Quote