Navigation rules are those rules provided by JSF Framework that describes which view is to be shown when a button or a link is clicked.
Navigation rules can be defined in JSF configuration file named Navigation rules can contain conditions based on which the resulted view can be shown.
The actual Listener component is a JAR file containing two classes: Once this is done and a proper configuration is available, the component can be tested by just adding one of the configured parameters at the end of the URL: Assuming that the configuration is correct this should invoke the specified method on the backing bean.
In this article I will introduce my solution that is working well as a pragmatical real-world solution. As a matter of fact, in the Java Server Faces (JSF) framework communication between client and server is always “automatically” done via HTTP POST, the so-called “post-back” mechanism.
Although for some reasons this is obviously the right decision on how to implement post-backs, this solution has one major downside, although not really a technical one: As parameters are not being passed within the URL, usage of the URL– for bookmarking, posting deeplinks to other pages and the like– is impossible.
The one remaining question is how links can be created inside of JSF pages that are using this mechanism. So the number of tags to be taken care of is limited.
This is something the component doesn’t deal with at the moment which means it has to be done by hand. we are using it only for navigation purposes (according to requirement no. Everything else is still being done by JSF because it’s just not interesting to see other things within the URL.
tell the session, that the current page to display now has the ID 123).
Looking at JSF, this is done by posting back values from the client to Java Objects on the server within the lifecycle phase “Update Model Values.” Now we want to do the same but taking parameters from our URL and posting them to our backing beans.
In this case, you only need to put view name in action attribute and JSF will search the correct view page automatically in the deployed application.
Set view name in action attribute of any JSF UI Component.
That way every configured parameter can modify objects within the current session.
What we need to be able to configure now is the following: As the class tries to open the XML file from “/url-parameter-configuration.xml” it must be available within the classpath.
Two popular ways would be to put that file directly into the web application or to put it into a JAR and place the JAR into the /WEB-INF/lib directory of the web application.