Primefaces Panel

时间:2012-03-20 17:13:11

标签: primefaces

有没有办法让它当我点击一个p:按钮时出现一个隐藏的p:面板,并在下次渲染时再次隐藏?

            <h:commandButton id="saveButton"  value="save" oncomplete="cartComplete.show();">
            </h:commandButton>
            <p:panel widgetVar="cartComplete">
                Shopping Cart Saved
            </p:panel>

3 个答案:

答案 0 :(得分:2)

试试这个......

<p:commandButton value="Save" action="#{myBean.setPanelVisibility}" update=":myForm:myPanel"/>
<p:panel id="myPanel" rendered="#{myBean.renderPanel}"/>

在bean中切换renderPanel属性。

答案 1 :(得分:1)

你去......

<h:body>
    <h:form prependId="false">
        <p:panel id="myPanel" style="display:none">
            Shopping Cart Saved
        </p:panel>
        <p:commandButton id="show" value="show" onclick="jQuery('#myPanel').show()">
        </p:commandButton>
        <p:commandButton id="hide" value="hide" update="myPanel">
        </p:commandButton>
    </h:form>
</h:body>

说明:style =“display:none”使面板被隐藏,当你想显示它时,使用jquery(已经有了primefaces).show()函数,最后是update="myPanel"的第二个命令按钮将重新渲染面板,它将再次隐藏...


更新

styleClass同样的想法,使用styleClass="hide"(而不是style="display:none"

你的css在哪里

.hide {
    display:none;
}

答案 2 :(得分:0)

在java类

private String renderPanel =&#34; false&#34;; <p:commandButton value="Save" action="#{myBean.setPanelVisibility}" update="myPanel"/> <p:panel id="myPanel" rendered="#{myBean.renderPanel=='true'}"/>

相关问题