Navigation Model in JSF – Static Navigation

What is Navigation:
A website is a collection of web pages. Moving between web pages of a website is known as Navigation. User can switch from one webpage to another in any of these following ways,

  • Clicking a button
  • Clicking Hyperlink
  • Typing URL

Types of Navigation:

  • Static Navigation
  • Dynamic Navigation

Static Navigation:
Best example of Static Navigation is clicking on hyperlinks. A hyperlink may navigate the user to other webpages in the same website or different website. When the users click the hyperlink they are moved to the webpage linked to that hyperlink. This type of navigation, where user is moved to fixed webpage is known as Static Navigation.

Static Navigation Example: (Implicit Navigation)
page1.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:c="http://java.sun.com/jsf/core">
    <h:head>
        <title>Navigation Model</title>
    </h:head>
    <h:body>
        <h:form>
            Welcome to JSF
       <h:commandLink value="Welcome" action="page2"/>
        </h:form>
    </h:body>
</html>

page2.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Congrats! you have successfully completed static navigation!
    </h:body>
</html>

Output:
static1
After clicking the link it navigates to page 2,
static2

By Sri

Leave a Reply

Your email address will not be published. Required fields are marked *