在這裏你去...
<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>
解釋:風格=「顯示:無」使面板被隱藏,並whenver要顯示它使用jquery(與primefaces已經自帶).show ()函數,第二個命令按鈕的最後update="myPanel"
將重新呈現面板,它會再次隱藏...
更新
只是01同樣的想法,在Java類
私人字符串renderPanel = 「假」 使用styleClass="hide"
(而不是style="display:none"
)
凡在你的CSS
.hide {
display:none;
}
_「並且在下次渲染時再次隱藏」_這是什麼意思?頁面重新加載? – 2012-03-20 19:02:37