Suppose the following:
In a jar file you have a META-INF/faces-config.xml file with the following navigation rule:
<navigation-rule>
<from-view-id>/path/page1.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/path/result.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
And I would like to override this navigation rule in my web application, so I put the following navigation rule in WEB-INF/faces-config.xml as follows:
<navigation-rule>
<from-view-id>/path/page1.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/path/my_custom_result.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
So when I am in the page /path/page1.xhtml and an action outcome is success I suppose that the navigation case in WEB-INF/faces-config.xml is the outcome (i.e. /path/my_custom_result.xhtml) but unfortunatly the outcome is the one in the jar META-INF/faces-config.xml (i.e. /path/result.xhtml). Although looking at the code those two cases are in a java.util.Set so the order is not even guaranteed!
the first question is do you think this is a bug? although in the JSF specification this situation is not mentioned, but I think its good sense to have the local faces-config.xml configurations override the ones in the jar files.
second question is: I know that I can create a custom NavigationHandler, but looking to the com.sun.faces.application.NavigationHandlerImpl I didn't understand how I could know from which faces-config.xml file a NavigationCase comes.
Any ideas or suggestions?
Thanks guys.
Regarding Eelke answer:
This is the ADF documentation, what I was looking is the JSF 2.0 specification that you can find here: http://download.oracle.com/otndocs/jcp/jsf-2.0-fr-eval-oth-JSpec/ and there I found the following line
It is an error to specify more than one <navigation-case>,nested
within one or more <navigation-rule> elements with the same
<from-view-id>matching pattern, that have exactly the same combination
of <from-xxx>, unless each is discriminated by a unique <if> element.
Which makes me think that what I am trying to do is not possible although some JSF implementations could have a slight different behavior for this situation (ADF for example).
Regarding the duplicates the NavigationCase.equals method checks that all the attributes are the same, and in my case the toViewID is different so they are not equal.
Set
never guarantees the order. You're wrong. It's theSet
implementation which controls that. TheHashSet
for example does indeed not guarantee the order. TheTreeSet
guarantees the order by sorting. TheLinkedHashSet
guarantees the order by insertion. The JSF implementation usesLinkedHashSet
to collect navigation cases. The main difference betweenSet
andList
is that theSet
guarantees uniqueness (i.e. no duplicate elements allowed). – BalusC