tags:

views:

343

answers:

0

Hello Friends..

I have a page called mainMenu.xhtml in which header.xhtml and sideMenu.xhtml and one more content page is included.

My requirement is based on the item selected from the sideMenu the page should navigate to corresponding page that is penMenu.xhtml or PensilMenu.xhtml But when I click the menu item it is not navigating to the required page Its displaying the same page again.. I have defined the navigation in faces-config.xml. I could not figureout whats going wrong.. Can any one help me out in doing that.

mainMenu.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"&gt;
 <body>
<ui:composition template="./welcomeTemplate.xhtml">
   <ui:define name="header">
     <ui:include src="./header.xhtml"/>
 </ui:define>
 <ui:define name="leftColumn">
    <ui:include src="./sideMenu.xhtml"/>
 </ui:define>
 <ui:define name="content" >

         <ui:include src="./welcome.xhtml"/>
 </ui:define>
</ui:composition> 
</body>
</html>

header.xhtml

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:face="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich"
 xmlns:ui="http://www.sun.com/web/ui"&gt;
    <a4j:loadStyle src="/resources/css/stylesheet.css" />
    <head>
    <title> </title>
    </head>

    <body>

    <rich:panel>
    <h:outputText value="Hi ABC"></h:outputText>
    </rich:panel>
    </body>
    </html>

sideMenu.xhtml

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:face="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich"
 xmlns:ui="http://www.sun.com/web/ui"&gt;
    <a4j:loadStyle src="/resources/css/stylesheet.css" />
    <head>
    <title> </title>
    </head>

    <body>

    <rich:panel>
    <h:outputText value="Hi ABC"></h:outputText>
    </rich:panel>
    </body>
    </html>

penMenu.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"&gt;
<body>
<ui:composition template="./welcomeTemplate.xhtml">
 <ui:define name="header">
     <ui:include src="./header.xhtml"/>
 </ui:define>
 <ui:define name="leftColumn">
    <ui:include src="./sideMenu.xhtml"/>
 </ui:define>
 <ui:define name="content" >
     penMenu
 </ui:define>
 </ui:composition> 
 </body>
 </html>

pensilMenu.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"&gt;
<body>
<ui:composition template="./welcomeTemplate.xhtml">
 <ui:define name="header">
     <ui:include src="./header.xhtml"/>
 </ui:define>
 <ui:define name="leftColumn">
    <ui:include src="./sideMenu.xhtml"/>
 </ui:define>
 <ui:define name="content" >
     pensilMenu
 </ui:define>
 </ui:composition> 
 </body>
 </html>

faces-config.xml

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

    <faces-config
    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"
    version="1.2">
 <managed-bean>
  <managed-bean-name>pageDisplayer</managed-bean-name>
  <managed-bean-class>PageDisplayer</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
 <navigation-rule>
  <display-name>mainMenu.xhtml</display-name>
  <from-view-id>/mainMenu.xhtml</from-view-id>
  <navigation-case>
   <from-outcome>pen</from-outcome>
   <to-view-id>/penMenu.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>
 <navigation-rule>
  <display-name>mainMenu.xhtml</display-name>
  <from-view-id>/mainMenu.xhtml</from-view-id>
  <navigation-case>
   <from-outcome>pensil</from-outcome>
   <to-view-id>/pensilMenu.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>
    </faces-config>

ManagedBean

import javax.faces.context.FacesContext;

public class PageDisplayer {

 public String sideBarAction()
 {
            /**
            * Get the request parameter map from the context, so that we can find which link of the side is clicked
            */
            FacesContext context = FacesContext.getCurrentInstance();
            String selectedPageViewId =
                   context.getExternalContext().getRequestParameterMap().get("pageViewId");

            System.out.println(selectedPageViewId);
            return selectedPageViewId;
  }

Thanks A lot In advance....