我动态地在我的页面中包含一个primefaces项目样式的xhtml页面。在第一次请求时,我可以在包含页面上找到 facesmessgae。然后输入 ajax 验证不起作用,没有任何验证,不起作用。commandButton 不起作用。
包含页面
.ui-slidemenu-content{高度:300px; } $(function() { $("#addfoodtogg").toggle(); });
</h:head>
<h:body>
<ui:include src="../header.xhtml"/>
<p:layout style="min-width:240px;min-height:650px" id="layout">
<p:layoutUnit id="left" position="west" size="250" resizable="true" closable="false" collapsible="true" header="系统管理" minSize="250" >
<h:form>
<p:slideMenu backLabel="返回" >
<p:submenu label="食品管理" icon="ui-submenu-foodmanager">
<p:submenu label="食品管理" icon="ui-submenu-foodsmanager">
<p:menuitem value="添加食品" actionListener="#{menuManagerController.oper('addfood')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-foodsmanager-add" />
<p:menuitem value="管理食品" actionListener="#{menuManagerController.oper('managerfood')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-foodsmanager-manager" />
</p:submenu>
<p:submenu label="食品种类管理" icon="ui-submenu-foodcatemanager">
<p:menuitem value="添加种类" actionListener="#{menuManagerController.oper('addfoodcate')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-foodcatemanager-add " />
<p:menuitem value="管理管理" actionListener="#{menuManagerController.oper('managerfoodcate')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-foodcatemanager_manager" />
</p:submenu>
</p:submenu>
<p:submenu label="菜单管理" icon="ui-submenu-foodmenumanager">
<p:menuitem value="添加菜单" actionListener="#{menuManagerController.oper('addfoodmenu')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-foodmenumanager-add" />
<p:menuitem value="管理菜单" actionListener="#{menuManagerController.oper('managerfoodmenu')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-foodmenumanager-manager" />
</p:submenu>
<p:submenu label="用户管理" icon="ui-submenu-usermanager">
<p:menuitem value="添加用户" actionListener="#{menuManagerController.oper('adduser')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-usermanager-add" />
<p:menuitem value="用户管理" actionListener="#{menuManagerController.oper('manageruser')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-usermanager-manager" />
<p:menuitem value="权限设置" actionListener="#{menuManagerController.oper('xx')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-usermanager-poweredit" />
</p:submenu>
<p:submenu label="系统配置" icon="ui-submenu-sysmanager">
<p:menuitem value="基础配置" actionListener="#{menuManagerController.oper('xx')}" update=":#{p:component('centerpanel')}" icon="ui-submenu-sysmanager-basic" />
</p:submenu>
</p:slideMenu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<p:panel id="centerpanel" >
<ui:decorate template="#{menuManagerController.panelurl}"></ui:decorate>
</p:panel>
</p:layoutUnit>
<p:layoutUnit position="south" ></p:layoutUnit>
</p:layout>
<ui:include src="../tail.xhtml"></ui:include>
</h:body>
</html>
它包含页面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:panel>
<h:form>
<p:growl id="addfoodymsg" showDetail="true" life="3000" autoUpdate="true"/>
<p:panelGrid columns="4">
<p:outputLabel for="foodname" value="食品名称" >
</p:outputLabel>
<p:inputText id="foodname" value="#{foodManagerController.foodName}" >
<f:validateRequired/>
<f:validator validatorId="foodIsExistValidator"/>
<p:ajax update="addfoodymsg" event="keyup"/>
</p:inputText>
<p:outputLabel for="fooddesc" value="食品描述" >
</p:outputLabel>
<p:inputText id="fooddesc" value="#{foodManagerController.foodDesc}" >
<f:validateRequired/>
<p:ajax update="addfoodymsg" event="keyup"/>
</p:inputText>
<p:outputLabel for="foodprice" value="食品价格(元)" >
</p:outputLabel>
<p:inputText id="foodprice" value="#{foodManagerController.price}" >
<f:validateRequired/>
<f:validateDoubleRange/>
<p:ajax update="addfoodymsg" event="keyup"/>
</p:inputText>
<p:outputLabel for="foodUnitinput" value="计量单位">
</p:outputLabel>
<p:selectOneMenu value="#{foodManagerController.foodUnit}"
id="foodUnitinput" panelStyle="width:150px" effect="explode" style="width:160px"
immediate="true"
>
<f:selectItems value="#{foodManagerController.foodUnits}" var="foodunits"
itemLabel="#{foodunits}" itemValue="#{foodunits}"/>
</p:selectOneMenu>
<p:outputLabel for="favfoodprice" value="优惠价格" >
</p:outputLabel>
<p:inputText id="favfoodprice" value="#{foodManagerController.favourablePrice}" >
<f:validateRequired/>
<f:validateDoubleRange/>
<p:ajax update="addfoodymsg" event="keyup"/>
</p:inputText>
<p:outputLabel for="foodcatselect" value="食品种类">
</p:outputLabel>
<p:selectOneMenu value="#{foodManagerController.foodCategory}"
id="foodcatselect" panelStyle="width:150px" effect="explode" style="width:160px"
converter="categoryconvertor" immediate="true"
>
<f:selectItems value="#{foodCateManagerController.foodCategories}" var="foodcat"
itemLabel="#{foodcat.typeName}" itemValue="#{foodcat}"/>
</p:selectOneMenu>
<p:outputLabel for="foodstate" value="食品状态">
</p:outputLabel>
<p:selectOneMenu value="#{foodManagerController.bustate}"
id="foodstate" panelStyle="width:150px" effect="explode" style="width:160px"
immediate="true"
>
<f:selectItems value="#{foodManagerController.foodBustate}" var="foodstate"
itemLabel="#{foodstate}" itemValue="#{foodstate}"/>
</p:selectOneMenu>
</p:panelGrid>
<p:commandButton id="addacate" value="添加" actionListener="#{foodManagerController.addFood()}" ajax="true"/>
</h:form>
</p:panel>
</h:body>
</ui:composition>