I'm modernizing a JSF web application I took over from someone who retired and is not available for questions.
Current job is to simplify a h:dataTable. Each record has a commandLink to go to the corresponding details page.
Old version: action method openDetail(), determined the selected record by binding of the dataTable and looping trough the records to get the row.
New version: action method is now openDetail(Long id) and of course I added the parameter to the command link as well.
My action method is called with the correct parameter, I verified this by adding some log output. But the navigation-rule is not effective anymore. Although the action method returns the correct outcome, it stays on the page with the table.
The navigation-rule in faces-config.xml looks like this:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-action>#{myBean.openDetail}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/mysks/detail.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
Do I need to adapt the navigation-rule ? Does JSF make a difference for overloaded action methods ?
The
<from-action>has to exactly match the literal string as defined inactionattribute.So if it currently looks like this:
Then the
<from-action>must be exactly that literal string:However, the whole navigation rule system has not proven to be really useful in JSF and has become de-facto deprecated since release of JSF 2.0 in 2009 which introduced the new support for immediately returning the
<to-view-id>as return value, called "implicit navigation". Essentially, XML-based navigation rules are really a "leftover" of the jurassic JSF 1.x and you'd best just get rid of them.So if you simply adjust the
openDetail()method fromto
then you can get rid of the entire
<navigation-rule>bloat from thefaces-config.xml.See also: