Reply To: JSF actions using Rewrite

Splash Forums Rewrite Users JSF actions using Rewrite Reply To: JSF actions using Rewrite

#23823

Hi Willdurman,

Yes! There is a way to do this using Rewrite, which is actually the core mechanism that Rewrite uses to execute PrettyFaces action methods in the compatibility module.


      return ConfigurationBuilder
               .begin()
               .addRule()
               .when(Path.matches("/name/{name}"))
               .perform(PhaseAction.retrieveFrom(El.retrievalMethod("#{expressionLanguageBean.action}"))
                        .after(PhaseId.RESTORE_VIEW)
                        .and(Forward.to("/expression-language.xhtml")))
               .where("name").bindsTo(PhaseBinding.to(El.property("#{expressionLanguageBean.name}"))
                        .after(PhaseId.RESTORE_VIEW));

This handles both EL value injection, but also EL method invocation using the PhaseAction deferred operation handler. It should be pretty self-explanatory from here, but let me know if anything is confusing. I know it seems simple to the guy who wrote it, and that doesn’t always carry through to others!