This content has been marked as final.
Show 1 reply
-
1. Re: Redirecting before rendering the page, if some condition
ericjava.eric.chiralsoftware.net Feb 26, 2008 10:11 AM (in response to ericjava.eric.chiralsoftware.net)I searched around some more after asking, and found this page with a handy trick:
In essence, you create a
dummy
action, which can in fact be a true noop:@Name("helpfulPojo") public class HelpfulPojo { public void noop() { } }
And then in pages.xml you do a trick like this:
<page action="#{helpfulPojo.noop}" view-id="/protected/show-invoice.xhtml"> <navigation from-action="#{helpfulPojo.noop}"> <rule if="#{true}"> <redirect view-id="/protected/invoice-search.xhtml"/> </rule> </navigation> </page>
And obviously, you would use some EL expression that's more meaningful than if="#{true}".
It works! The action attribute's method binding gets called before rendering, and that then hits the navigation rule because of the from-action attribute on it.
Note the use of <redirect>, not a navigate-to or something like that.