I want an action method to be run when my page is accessed by a redirect or GET, but if an action is performed by the user on the page through a commandLink or commandButton, I want that action method to run. I thought I could do that by creating a page action like this:
<page view-id="/peopleSearch.xhtml" action="#{peopleSearch.findAllPeople}"> <navigation> <rule if-outcome="viewPerson"> <redirect view-id="/person.faces"/> </rule> </navigation> </page>
... <a4j:commandButton value="Search" action="#{peopleSearch.findPeople}" reRender="results"/> ...
You can pass along a parameter with the button and check for that in the action to see if it was entered through a button. Perhaps even add that as a condition in pages.xhtml.