[英]How to hide/show a panel conditionally in primefaces/jsf2 on commandButton click?
我想在某些情況下在commandButton單擊上隱藏/顯示<p:panel>
,我嘗試了以下
<h:form>
// some tag here
<p:commandButton value="EDIT" ajax="false"
onclick="if(#{bean.status == 'ACTIVE'}){editable.show();}"
actionListener="#{beanMgnt.edit}">
</h:form>
可編輯的面板是
<p:panel widgetVar="editable" closable="true"
toggleable="true" visible="false">
// some tags here
</p:panel
編輯方法僅執行sysout。
最終用戶單擊該按鈕時我想要的是,該面板將顯示為帶有可編輯文本框的Bean數據。
我想通過單擊按鈕使此面板可見,該怎么做?
您還必須在按鈕中使用update =“ <id>” ...因此,例如,您將需要<p:commandButton ... update =“ thepanelid” ... /> <p:panel id =“ thepanelid“ ...
我認為您可以在后備bean中使用布爾值屬性。 在面板中,您輸入了: visible="backingbean.yourAttribute"
並在bean中使用一種方法通過onclick對其進行控制。
onclick="backingbean.theMethod"
在該方法中,如果您的條件得到驗證,則可以將屬性設置為“ true”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.