I have a strange problem with a JSF2 application. I'll try to describe it in detail.
My home page has eight links: 5 on the header and 3 on the footer. I also have a search component which I need to show -- once the user is logged in -- for 3 of those pages. The way I'm doing it is by passing a "fromPage" attribute in the session, and making a decision to show, or hide the search component.
When I am using <h:commandLink> for all my home page links it all works fine. But another problem arises: the JSF url's are trailing by one click. This is a known issue so I wont' go into detail explaining it, but simply put when I click on "Contact Us" from the "Home" page the pages changes to the Contact Us page but in the URL I'm still on the home page. Which creates a completely unintuitive environment for the user.
So I moved all my links to <h:link>. Now the url's change every click and it behaves normally. But now all the "outcome" methods -- for all 8 links on the home page -- are called from left to write, top to bottom ON EVERY CLICK TO WHICHEVER PAGE. The url changes correctly and the page is displayed correctly but the "fromPage" attribute in the session is always for the last link called: the one at the bottom right.
To make things even more bizarre, my Search component is always showing, because the last link on the header is for one that it should show for. When I test this by putting another link on the page -- at the top right, just before the Search component -- for a page the Search shouldn't show for, the Search doesn't show. Ever. No matter which page I'm clicking to.
I can simply give up on the url's showing the correct page, switch back to commandLinks, and move on with my life. But I want to get it right, and help my users. Is there a solution?
(If this is not clear enough and you need more information please let me know!)