使用ajax primefaces渲染panelgrid

beg*_*ass 2 java rendering java-ee primefaces jsf-2

我有这个

<p:selectOneMenu  id="dec" value="#{editCommandController.myCom.decision}" >  
                        <f:selectItems value="#{editCommandController.decisions}" />  
                        <p:ajax update="etat :myform:alors" event="change" />
                    </p:selectOneMenu>  
Run Code Online (Sandbox Code Playgroud)

它允许禁用它

<p:selectOneMenu  id="etat" value="#{editCommandController.myCom.etat}" disabled="#{editCommandController.myCom.decision eq 'rejettée'}" >  
                        <f:selectItems value="#{editCommandController.etats}" />   
                    </p:selectOneMenu> 
Run Code Online (Sandbox Code Playgroud)

当检查条件时,我还想在检查相同条件时隐藏此panelgrid:

 <h:panelGrid id="alors"   rendered="#{editCommandController.myCom.decision ne 'rejettée'}" >
                    <p:dataTable id="cars" style="width: 80px;" var="car" value="#{editCommandController.pdm}" paginator="true" rows="10"  
                                 selection="#{editCommandController.selectedPapier}" selectionMode="single" >  

                        <p:ajax event="rowSelect" listener="#{editCommandController.onRowSelect()}"   
                                update=":myform:jesuis" />  

                        <f:facet name="header">  
                            RadioButton Based Selection  
                        </f:facet>                    

                        <p:column headerText="libelle">  
                            #{car.libelle}  
                        </p:column>  

                        <p:column headerText="format">  
                            #{car.format}  
                        </p:column>  

                        <p:column headerText="stock" >  
                            #{car.stock}  
                        </p:column>  

                    </p:dataTable>  


                    <h:outputText  id="jesuis" value=" c est la papier : #{editCommandController.selectedPapier.libelle}"  />


                    <h:panelGrid columns="2" cellpadding="5" style="margin-top: 22px;">  
                        <h:outputLabel value="Reliure :" for="city" />
                        <p:selectOneMenu id="city" value="#{addPapierController.choixReliure}">  
                            <f:selectItem itemLabel="choisir reliure" itemValue="" />  
                            <f:selectItems value="#{addPapierController.libelleReliures}" />  
                            <p:ajax 
                                listener="#{addPapierController.handleCityChange}" />  
                        </p:selectOneMenu>
                    </h:panelGrid>

                </h:panelGrid>
Run Code Online (Sandbox Code Playgroud)

但我注意到,当第一次加载页面时,它会检查panelgrid的panelgrid

你有没有想过要像上面的selectonemenu一样继续使用这个功能,谢谢

dam*_*ian 5

用panel围绕panelGrid p:outputPanel.然后,在"dec"selectOneMenu中,还更新outputPanel.假设所有这些组件都在同一个表单中,它将如下所示:

<p:selectOneMenu  id="dec" value="#{editCommandController.myCom.decision}" >  
       <f:selectItems value="#{editCommandController.decisions}" />  
       <p:ajax update="etat gridContainer :myform:alors" event="change" />
</p:selectOneMenu>  

<p:outputPanel id="gridContainer" layout="block" >
    <h:panelGrid id="alors" rendered="#{editCommandController.myCom.decision ne 'rejettée'}" >
         <!-- panel grid contents here.. -->  
    </h:panelGrid>
</p:outputPanel>
Run Code Online (Sandbox Code Playgroud)