0

行エディターモードでデータテーブルを使用してフォームを設定し、入力バリデーターがあるかどうかを確認します。はるかに、validator.so を使用した入力コンポーネントを含むグリッド フォームでグリッドを見つけることができません。2つのフォームを設定すると、各フォームで他のコンポーネントを見つけることができません。: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>
4

1 に答える 1

0

Primefaces には、指定された ID を探して (ルートから) ビュー全体を実行し、JSF クライアント ID を返す、きちんとした小さなユーティリティ関数があります。

p:component('compentid')

次のように使用できます (先頭の「:」を忘れないでください):

<p:commandButton ... update=":#{p:component('compentid')}" />

これにより、ID だけでビュー内の任意のコンポーネントを効果的に取得できます。それがどのような形であるかを知る必要さえありません。

于 2013-07-29T16:12:04.617 に答える