I have a JSF page that is working and I am now adding a menu in the index.xhmtl to call the working JSF page.
My index.xhtml includes another xhtml file (header.xhtml). Both index.xhtml and header.xhtml have EL expressions in them and both share the same managed bean (MenuView). When I run it, the MainView backing bean is never being instantiated.
Following is the index.xhtml:
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Provisioner</title>
</h:head>
<h:body>
<ui:include src="/header.xhtml" />
<h:form>
<p:panelMenu style="width:800px">
<p:submenu label="Application Configuration">
<p:menuitem value="Configure WebLogic Domain" url="#" disabled="#{!menuView.isMWAdmin}" />
</p:submenu>
<p:submenu label="Internal Data Management">
<p:menuitem value="Domain Types" outcome="/domainTypeList.xhtml" />
</p:submenu>
</p:panelMenu>
</h:form>
</h:body>
</html>
The header.xhtml:
Code: Select all
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<p:panel>
<p:panelGrid columns="2" styleClass="ui-noborder">
<h:graphicImage value="/resources/images/usfoodsLogo.png"></h:graphicImage>
<h1>US Foods Middleware Software Provisioner</h1>
</p:panelGrid>
<p:panel>
<p:panelGrid columns="2" styleClass="ui-noborder" >
<f:facet name="header">
<h:outputLabel value="Logged in as: " />
<h:outputText value="#{menuView.currentUser}" />
</f:facet>
</p:panelGrid>
<p:panelGrid columns="2" styleClass="ui-noborder" >
<f:facet name="header">
<h:outputLabel value="Current Environment: " />
<h:outputText value="#{menuView.currentEnv}" />
</f:facet>
</p:panelGrid>
</p:panel>
</p:panel>
</ui:composition>
The backing bean code:
Code: Select all
package com.usf.provisioner.view;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import com.usf.provisioner.util.ApplicationProperties;
@ManagedBean
public class MenuView implements Serializable {
private static final long serialVersionUID = -1391369095648565176L;
private String currentUser;
private boolean isMWAdmin;
private boolean isUSFProvisionerAdmin;
private String currentEnv;
public MenuView() {
super();
HttpServletRequest req = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
currentUser = req.getUserPrincipal().getName();
isMWAdmin = req.isUserInRole("MWAdmin");
isUSFProvisionerAdmin = req.isUserInRole("USFProvisionerAdmin");
currentEnv = ApplicationProperties.envProperties.getProperty("env-name");
}
public String getCurrentUser() {
return currentUser;
}
public void setCurrentUser(String currentUser) {
this.currentUser = currentUser;
}
public boolean isMWAdmin() {
return isMWAdmin;
}
public void setMWAdmin(boolean isMWAdmin) {
this.isMWAdmin = isMWAdmin;
}
public boolean isUSFProvisionerAdmin() {
return isUSFProvisionerAdmin;
}
public void setUSFProvisionerAdmin(boolean isUSFProvisionerAdmin) {
this.isUSFProvisionerAdmin = isUSFProvisionerAdmin;
}
public String getCurrentEnv() {
return currentEnv;
}
public void setCurrentEnv(String currentEnv) {
this.currentEnv = currentEnv;
}
}
I left the security measure off of the Domain Types menu item so that I could test that feature and it still works.
A little more background information: This used to work with Primefaces 5.2, WebLogic Server 12.1.3, Mojarra 2.2.0 and Java 1.8.0_61.
I have searched this forum and others, but have not found a solution. Any help is appreciated.