我发现如果我用行编辑器模式设置了一个带有数据表的表单,并且有输入验证器。更多,一个带有验证器的输入组件的网格。所以我在表格中找不到网格。如果我设置两个表单,我无法在每个表单中找到其他组件。我找到了带有 :formid:compentid 的组件。我只想使用删除按钮编辑 foodcategoryform 并使用更新 foodcategoryform 添加类别。但它不能...primefaces.thank u。
<p:tab title="食品分类" id="foodtab">
<h:form id="foodcategoryform">
<f:facet name="header">
</f:facet>
<p:dataTable id="categorytable" var="foodcategories"
value="#{foodManagerController.foodCategories}"
editable="true"
paginator="true"
paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" rows="5"
paginatorAlwaysVisible="false"
emptyMessage="当前系统没有分类数据"
editMode="row"
resizableColumns="true"
>
<p:ajax event="rowEdit" update="@this" listener="#{foodManagerController.updateFoodCategory}" />
<p:column headerText="名称" style="width:25%">
<p:growl id="categorymsg"></p:growl>
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{foodcategories.typeName}" /></f:facet>
<f:facet name="input">
<p:inputText value="#{foodcategories.typeName}" >
<f:validator validatorId="foodCateIsExistValidator" />
<f:attribute name="objectid" value="#{foodcategories.id}"></f:attribute>
<p:ajax update="categorymsg" event="keyup" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="描述" style="width:25%">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{foodcategories.typeDesc}" /></f:facet>
<f:facet name="input"><p:inputText value="#{foodcategories.typeDesc}" ><f:validateRequired/></p:inputText></f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:6%" headerText="修改">
<p:rowEditor />
</p:column>
<p:column style="width:6%" headerText="删除">
<f:facet name="header">
<h:outputText value="删除" />
</f:facet>
<p:commandButton id="deletebutton" update="categorytable" icon="ui-icon-close" title="删除" actionListener="#{foodManagerController.deletedFoodCatery(foodcategories)}" ajax="true">
</p:commandButton>
</p:column>
</p:dataTable>
<p:panel header="新加种类" toggleable="true" toggleSpeed="500" id="addcategorypanel" >
<p:growl id="addcategorymsg" showDetail="true" life="3000" autoUpdate="true"/>
<p:outputLabel for="typename" value="种类名称" >
</p:outputLabel>
<p:inputText id="typename" value="#{foodManagerController.foodCateName}" >
<f:validateRequired/>
<f:validator validatorId="foodCateIsExistValidator" />
<p:ajax update="addcategorymsg" event="keyup"/>
</p:inputText>
<p:outputLabel for="typedesc" value="种类描述"></p:outputLabel>
<p:inputText id="typedesc" required="true" requiredMessage="请添加描述" value="#{foodManagerController.foodCateDesc}">
<f:validateRequired/>
<p:ajax update="addcategorymsg" event="keyup" />
</p:inputText>
<p:commandButton id="addacate" update="addcategorymsg,categorytable" value="添加" actionListener="#{foodManagerController.addFoodCatery}" ajax="true"/>
</p:panel>
</h:form>
</p:tab>