JSF 2.0 implicit navigation, different views

I am looking for a good explanation of JSF 2.0 implicit navigation and how it works with views. To be more precise, I understand that from the action method I can return a string that is the result of the action. If there is a JSF view whose file name matches the result, then this is implicit navigation.

Now ... my question is: what if the action is called from a view that is inside the folder, but the view that I want to go to the next is in a different folder? Ie, from /manager/edit.xhtml action is called. Which line should this action return so that the navigation system can safely jump to /user/list.xhtml or /index.xhtml or /manager/index.xhtml ?

+4
source share
2 answers

As far as I know, JSF is looking for a suitable view only in the current context. You probably need to define a navigation rule in your faces-config.xml in order to handle the result in a special way. Here is an example:

 <navigation-rule> <from-view-id>/profiles/viewkeypages.xhtml</from-view-id> <navigation-case> <from-outcome>editkeypage</from-outcome> <to-view-id>/users/editkeypage.xhtml</to-view-id> <redirect /> </navigation-case> </navigation-rule> 

-Praveen.

+1
source

You can use implicit navigation to access views in other folders.

Just do something similar in the view:

 <h:link value="Move" outcome="#{request.contextPath}/users/editkeypage.xhtml?faces-redirect=true" /> 

or

 <h:link value="Move" outcome="/users/editkeypage.xhtml?faces-redirect=true" /> 
0
source

Source: https://habr.com/ru/post/1346641/


All Articles