java 使用 ajax primefaces 渲染面板网格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12263034/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:13:58  来源:igfitidea点击:

rendering panelgrid with ajax primefaces

javajakarta-eejsf-2primefacesrendering

提问by begiPass

I have this

我有这个

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

it allow to disable this

它允许禁用此功能

<p:selectOneMenu  id="etat" value="#{editCommandController.myCom.etat}" disabled="#{editCommandController.myCom.decision eq 'rejettée'}" >  
                        <f:selectItems value="#{editCommandController.etats}" />   
                    </p:selectOneMenu> 

when the condition is checked and I would like to also hide this panelgrid when the same condition is checked :

当检查条件时,我还想在检查相同条件时隐藏此面板网格:

 <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>

but I notice it check the panelgrid once the panelgrid when the page loads for the first time

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

do you any idea to make working this feature for all the time like for selectonemenu above, thanks

你有什么想法让这个功能一直工作,比如上面的 selectonemenu,谢谢

回答by damian

Surround the panelGrid with a p:outputPanel. Then, in the "dec" selectOneMenu, also update the outputPanel. Assuming all these components are inside the same form, it would look like this:

p:outputPanel.包围 panelGrid 。然后,在“dec”中选择OneMenu,同时更新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>