Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
 
 
Search All Tutorials
  

 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 
JSF
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

JSF Global Navigation Example

                          

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. There is an example of Global Navigation in JSF has been implemented with the complete downloadable solutions like the example code and the illustration about the procedure of deployment of example. This type of the navigation navigate directly to the other sources which have to mentioned as it is.

Here, you will find the code of the example and can get more about the global navigation in the JSF application in very efficient manner. This type of navigation does not works like an anchor tag (<a href=""></a>) of HTML (Hyper Text Markup Language). This type of navigation is shown by implementing the example in this section. There is the page that has to be referred in the example has been mentioned in the faces-config.xml file that is is handled by the action of the command button of the form from the page. You can see that the module of the code which is written in the faces-config.xml file that is like as follows:

	<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>
Above code makes the navigation rule in which the page and the action is mentioned. As you can see the value of the <from-view-id></from-view-id> is the "*" and the value of the <from-outcome></from-outcome> tage is "secondpage" which is the action of the command button and referred page is mentioned as the value of the <to-view-id></to-view-id> tag that mean the secondpage.jsp page can be referred on the occurring of the action "secondpage" from any page involved in the application which is determined by the "*" value.

There is an example has been given in this section for illustrating the topic more conveniently. This example shows command button labeled with the text "Go to second page". When you will click on the button pages is referred to an another page. This application uses some files for completion the application as given as below:

  • firstpage.jsp
  • secondpage.jsp

Program Output as follows:

When you will click on the command button component it will show the output as follows:

Code for the firstpage.jsp file:

<%@ 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.

                          

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (post your own) View All Comments Latest 10 Comments:

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Hot Web Programming Job

Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.