Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

JSF%20Interview%20Questions%20and%20Answers

Question: How to declare the Navigation Rules for JSF?
Answer: Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. For ex. for a login page, after the login gets successful, it should go to Main page, else to return on the same login page, for that we have to code as:

<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/main.jsp<to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>fail</from-outcome>
<to-view-id>/login.jsp<to-view-id>
</navigation-case>
</navigation-rule>

from-outcome to be match with action attribute of the command button of the login.jsp as:

<h:commandbutton value="Login" action="login"/>
Secondly, it should also match with the navigation rule in face-config.xml as


<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>core.jsf.LoginBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
In the UI component, to be declared / used as:


<h:inputText value="#{user.name}"/>
value attribute refers to name property of the user bean.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook