【问题标题】:Can 'update' attribute update two components simultanously?'update' 属性可以同时更新两个组件吗?
【发布时间】:2013-06-27 04:58:26
【问题描述】:

我有一个问题。是否可以一次更新两个组件? 我正在尝试这样的代码:

<h:panelGroup id="pickList">
    <p:panel  rendered="#{customCalender.visible}" widgetVar="searchTableBox">

    //Some codes.....

        <p:commandButton value="Cancel" update="pickList" actionListener="#{customCalender.closeList}" style="background:#25A6E1;color:red;font-family:'Helvetica Neue',sans-serif;font-size:10px;border-radius:4px;" />
        <p:commandButton value="Save" update="custDataTablePanel" actionListener="#{customCalender.saveTargetList}" style="background:#25A6E1;color:red;font-family:'Helvetica Neue',sans-serif;font-size:10px;border-radius:4px;"/>
   </p:panel>
</h:panelGroup>
....
.....
<h:panelGroup  id="custDataTablePanel">
   <p:panel rendered="#{customCalender.dataTableVisible}">
..
..
   </p:panel>
</h:panelGroup>

现在我想当我点击Save 按钮时隐藏&lt;h:panelGroup id="pickList"&gt; 并显示&lt;h:panelGroup id="custDataTablePanel"&gt; 所以我有两个布尔值来控制它们的可见性。但我需要更新其中两个面板。我用update="custDataTablePanel" 做的一个它在单击按钮后显示数据表。(在saveTargetList 方法中,我将custDataTablePanel 的可见性更新为true。)但无法隐藏面板pickList

所以我一直在徘徊,有什么方法可以一键隐藏和显示这两个面板。 请提出建议。

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:

    你可以在update属性中使用很多元素,用空格隔开

    <p:commandButton update="element1 element2"/> 
    

    您也可以使用update="@form"更新整个表单

    【讨论】:

    • 我试过这个&lt;p:commandButton update="element1 element2"/&gt;,但在这种情况下我的命令按钮不显示。
    • 它现在工作了..谢谢。可能是我以前做错了!无论如何谢谢.. :)
    • 谢谢..我不使用primefaces,但你的回答让我走上了正确的轨道..在selectOneMenu渲染属性中,工作方式相同,所以只是把所有组件的ID用空格分隔开来。 :)
    猜你喜欢
    • 2011-06-02
    • 1970-01-01
    • 1970-01-01
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多