Home Jsf JSF Global Navigation Example



JSF Global Navigation Example
Posted on: February 26, 2008 at 12:00 AM
This is a part of navigation in which one page is navigated to others. This section gives you something about the JSF Global navigation which makes the direct navigation between two or more pages.
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>
<html>
<head><title>Navigation Page</title></head>

<body>
<h1>This is the first page.</h1>
<h:form>
<h:commandButton value="Go to second page" 
action="secondpage" />
</h:form>
</body>
</html>
</f:view>

Code for the secondpage.jsp file:

<h4>This page is navigated by the firstpage.jsp that has been 
mentioned in the faces-config.xml file.
</h4>

Code for the faces-config.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.
//DTD JavaServer Faces Config 1.0//EN" "http://java.sun.com
/dtd/web-facesconfig_1_0.dtd">

<faces-config>
   <navigation-rule>
	<from-view-id>*</from-view-id>
	  <navigation-case>
		<from-outcome>secondpage</from-outcome>
		<to-view-id>/secondpage.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>
</faces-config>

Code for the web.xml file:

<?xml version="1.0"?> 
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.
//DTD Web Application 2.3//EN" "http://java.sun.com
/dtd/web-app_2_3.dtd">

<web-app>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD
</param-name>
        <param-value>server</param-value>
    </context-param>    

    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet
</servlet-class>
        <load-on-startup> 1 </load-on-startup>
    </servlet>

	<!-- Faces Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
</web-app>

Download This Complete Example.

Related Tags for JSF Global Navigation Example:
cdeploymentcomjsfionavigationdownloadmakeloadtypepagevisourceglobaldeploythislikejsexamplewithsolutionadatopagesglobexamaviprocbetweeneilitproceduresectionlipeimcompleteartceinpartasmntoutpartrtweenthinsolutionsletjadesemdiragerclobmeillustrationprododownctlxawhichxampsrectsourcessoeedirectetwatratiokisirhaimplementedllivnavmplepleplduandarcodcodestrrtutitwssrocthavbalstabablatigagatpleplprndodeonomolonl


More Tutorials from this section

Ask Questions?    Discuss: JSF Global Navigation Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.