Home Jsf Netbeans Adding Navigation in JSF Application
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Adding Navigation in JSF Application

Advertisement
This tutorial explains how to navigate from one jsp page to another jsp in JSF application.

Adding Navigation in JSF Application

        

This tutorial explains how to navigate from one jsp page to another jsp in JSF application. The page navigation in the JSF framework is controlled by the faces-config.xml. This file contains one or more navigation cases. You can map action from the commandButton to success.jsp and fail.jsp. Steps to navigate the jsp form using NetBeans IDE.

Step 1:- In the Projects window, double-click faces-config.xml to open the file in the Source Editor. In the toolbar above the file, click XML to display the file in plain XML.

Step 2:- Right-click anywhere in the file and choose JavaServer Faces > Add Navigation Rule. Type /login.jsp in the Rule from View field and optionally enter a description of the rule as figure below:

 

  

 

Step 3:- Right-click anywhere in the file and choose JavaServer Faces > Add Navigation Case. Type /login.jsp in the Form View and type success in Form Outcome and type /success.jsp in To View as figure below:

 

 

 

 

<?xml version='1.0' encoding='UTF-8'?>

<!-- =========== FULL CONFIGURATION FILE ========================== -->

<faces-config version="1.2" 
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
   http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
  <managed-bean>
  <managed-bean-name>SimpleLogin</managed-bean-name>
  <managed-bean-class>roseindia.SimpleLogin</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
  <navigation-rule>
  <from-view-id>/login.jsp</from-view-id>
  <navigation-case>
  <from-action>#{LoginForm.CheckValidUser}</from-action>
  <from-outcome>success</from-outcome>
  <to-view-id>/success.jsp</to-view-id>
  </navigation-case>
  <navigation-case>
  <from-action>#{LoginForm.CheckValidUser}</from-action>
  <from-outcome>fail</from-outcome>
  <to-view-id>/fail.jsp</to-view-id>
  </navigation-case>
  </navigation-rule>
  
</faces-config>

As per your requirement give another navigation rule. The faces-config.xml structure is as follows:


Download Source Code

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 10, 2009

Related Tutorials

Ask Questions?    Discuss: Adding Navigation in JSF Application   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
g
October 17, 2011
JSF2.0

there no longer is a faces-config.xml when starting a new project using jsf2.0
Smithd143
May 23, 2014
John

Link exchange is nothing else but it is just placing the other persons weblog link on your page at proper place and other person will also do similar in support of you. eegceeaafdkggkdk
DMCA.com