I have a selectonemenu in my jsf page and i need to navigate to different pages based on the value selected in the selectonemenu.
I tried two approaches:
2. Second approach is to navigate to the required page using response.sendRedirect in the valueChangeListener for the selectonemenu. With this approach, the control comes back to the initial page and no navigation happens.
Having said that, I move on to the actual submit button: your commandButton control. The way that command actions work in JSF is that their associated methods get called, and those methods return a String result. This result is looked up in the map defined in your JSF config XML file to determine where to go.
So, at its simplest, all you have to do is let the menu setter method store a command value, then return that command value on your command acttion, and map the command values to navigation specs in jsf-config.xml!
An IDE is no substitute for an Intelligent Developer.