我已在主要面孔选项卡中包含页面。我在每个页面中都使用了基于 id 的表单。当我为每个页面启用 ajax 时,它在选项卡中不起作用。
我的素面 index.xhtml 页面如下。
索引.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">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="templet.xhtml">
<ui:define name="top">
<h1>Qubit Student Management System</h1>
</ui:define>
<ui:define name="content">
<h:form id="menu">
<p:menubar autoDisplay="true">
<p:submenu id="admin" label="Admin">
<p:submenu id="institute" label="Institute Setup">
<p:menuitem id="addInstitute" value="Add Info" action="#{ajaxBean.editAction}" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="InstituteInformation"/>
</p:menuitem>
<p:menuitem id="viewInstitute" value="View Info" action="#{ajaxBean.editAction}" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="InstituteView"/>
</p:menuitem>
<p:menuitem id="editInstitute" value="Edit Info" action="#{ajaxBean.editAction}" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="InstituteEdit"/>
</p:menuitem>
</p:submenu>
<p:submenu id="campus" label="Campus Setup">
<p:menuitem id="addCampus" value="Add Campus" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="CampusInformation"/>
</p:menuitem>
<p:menuitem id="viewCampus" value="View Campus" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="CampusList"/>
</p:menuitem>
<p:menuitem id="editCampus" value="Edit Campus" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="CampusEdit"/>
</p:menuitem>
</p:submenu>
<p:submenu id="department" label="Department Setup">
<p:menuitem id="addDepartment" value="Add Department" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="DepartmentInformation"/>
</p:menuitem>
<p:menuitem id="viewDepartment" value="View Department" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="DepartmentList"/>
</p:menuitem>
<p:menuitem id="editDepartment" value="Edit Department" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="DepartmentEdit"/>
</p:menuitem>
</p:submenu>
</p:submenu>
<p:submenu id="student" label="Student">
<p:menuitem id="studentAdd" value="Student Add" action="#{ajaxBean.editAction}" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="StudentAdd"/>
</p:menuitem>
<p:menuitem id="studentList" value="Student List" action="#{ajaxBean.editAction}" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="StudentList" />
</p:menuitem>
<p:menuitem id="studentAdmission" value="Student Admission" action="#{ajaxBean.editAction}" ajax="true" update=":outputForm">
<f:setPropertyActionListener target="#{ajaxBean.action}" value="StudentAdmission" />
</p:menuitem>
</p:submenu>
</p:menubar>
</h:form>
<h:form id="outputForm">
<p:tabView id="outputTab">
<p:ajax event="tabClose" listener="#{ajaxBean.closeTab}"/>
<c:forEach items="#{ajaxBean.chcekItem}" var="item" varStatus="loop">
<p:tab id="#{item}" title="#{item}" closable="true">
<ui:include src="#{bundle[item]}"/>
</p:tab>
</c:forEach>
</p:tabView>
</h:form>
<a href="menuIteams.xhtml">Template</a>
</ui:define>
<ui:define name="bottom">
<h2 class="center">QubitLab Limited</h2>
</ui:define>
</ui:composition>
下面的其他一些页面。
研究所/Create.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">
<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">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.InstituteInfo}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:form id="institutesetupform">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:panelGrid columns="2">
<h:outputLabel value="#{bundle.CreateInstituteLabel_instituteCode}" for="instituteCode" />
<h:inputText id="instituteCode" value="#{instituteController.selected.instituteCode}" title="#{bundle.CreateInstituteTitle_instituteCode}" required="true" requiredMessage="#{bundle.CreateInstituteRequiredMessage_instituteCode}"/>
<h:outputLabel value="#{bundle.CreateInstituteLabel_instituteName}" for="instituteName" />
<h:inputText id="instituteName" value="#{instituteController.selected.instituteName}" title="#{bundle.CreateInstituteTitle_instituteName}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_location}" for="location" />
<h:inputText id="location" value="#{instituteController.selected.location}" title="#{bundle.CreateInstituteTitle_location}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_phone}" for="phone" />
<h:inputText id="phone" value="#{instituteController.selected.phone}" title="#{bundle.CreateInstituteTitle_phone}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_email}" for="email" />
<h:inputText id="email" value="#{instituteController.selected.email}" title="#{bundle.CreateInstituteTitle_email}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_fax}" for="fax" />
<h:inputText id="fax" value="#{instituteController.selected.fax}" title="#{bundle.CreateInstituteTitle_fax}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_web}" for="web" />
<h:inputText id="web" value="#{instituteController.selected.web}" title="#{bundle.CreateInstituteTitle_web}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_about}" for="about" />
<h:inputTextarea rows="4" cols="30" id="about" value="#{instituteController.selected.about}" title="#{bundle.CreateInstituteTitle_about}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_mission}" for="mission" />
<h:inputTextarea rows="4" cols="30" id="mission" value="#{instituteController.selected.mission}" title="#{bundle.CreateInstituteTitle_mission}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_vision}" for="vision" />
<h:inputTextarea rows="4" cols="30" id="vision" value="#{instituteController.selected.vision}" title="#{bundle.CreateInstituteTitle_vision}" />
<h:outputLabel value="#{bundle.CreateInstituteLabel_scop}" for="scop" />
<h:inputTextarea rows="4" cols="30" id="scop" value="#{instituteController.selected.scop}" title="#{bundle.CreateInstituteTitle_scop}" />
</h:panelGrid>
<br />
<h:commandButton action="#{instituteController.create}" value="#{bundle.CreateInstituteSaveLink}">
<f:ajax execute="institutesetupform" render="institutesetupform:messagePanel"/>
</h:commandButton>
<br />
</h:form>
</ui:define>
</ui:composition>
部门/Create.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">
<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">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.CreateDepartmentTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:form id="departmentsetupform">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:panelGrid columns="2">
<h:outputLabel value="#{bundle.CreateDepartmentLabel_departmentId}" for="departmentId" />
<h:inputText id="departmentId" value="#{departmentController.selected.departmentId}" title="#{bundle.CreateDepartmentTitle_departmentId}" required="true" requiredMessage="#{bundle.CreateDepartmentRequiredMessage_departmentId}"/>
<h:outputLabel value="#{bundle.CreateDepartmentLabel_departmentName}" for="departmentName" />
<h:inputText id="departmentName" value="#{departmentController.selected.departmentName}" title="#{bundle.CreateDepartmentTitle_departmentName}" />
<h:outputLabel value="#{bundle.CreateDepartmentLabel_history}" for="history" />
<h:inputText id="history" value="#{departmentController.selected.history}" title="#{bundle.CreateDepartmentTitle_history}" />
<h:outputLabel value="#{bundle.CreateDepartmentLabel_program}" for="program" />
<h:inputText id="program" value="#{departmentController.selected.program}" title="#{bundle.CreateDepartmentTitle_program}" />
</h:panelGrid>
<br />
<h:commandButton action="#{departmentController.create}" value="#{bundle.CreateDepartmentSaveLink}" >
<f:ajax execute="departmentsetupform" render="departmentsetupform:messagePanel"/>
</h:commandButton>
<br />
<br />
<h:commandButton action="#{departmentController.prepareList}" value="#{bundle.CreateDepartmentShowAllLink}" immediate="true"/>
<br />
</h:form>
</ui:define>
当单独运行每个页面时,ajax 可以找到表单 ID,但是当我通过单击菜单项将这些页面包含在index.xhtml页面选项卡中时,它会显示
<f:ajax> contains an unknown id 'departmentsetupform' - cannot locate it in the context of the component j_idt266
这里的任何人都在这方面帮助我..