简体   繁体   中英

How to hide/show a panel conditionally in primefaces/jsf2 on commandButton click?

I want to hide/show <p:panel> on commandButton click with some condition ,I tried following

<h:form>
// some tag here
<p:commandButton value="EDIT" ajax="false"
                        onclick="if(#{bean.status == 'ACTIVE'}){editable.show();}"
                        actionListener="#{beanMgnt.edit}">
</h:form>

and editable is a panel as

<p:panel widgetVar="editable" closable="true"
                toggleable="true" visible="false">
                // some tags here
            </p:panel

edit method is doing only sysout.

What I want when enduser clicks the button this panel will be visible with bean data populated with Editable text boxes.

I want to make visible this panel visible with button click.How to do that?

您还必须在按钮中使用update =“ <id>” ...因此,例如,您将需要<p:commandButton ... update =“ thepanelid” ... /> <p:panel id =“ thepanelid“ ...

I think you could use a boolean attribute in your backing bean. In the panel you put : visible="backingbean.yourAttribute" and you use a method in your bean to control it via onclick.

onclick="backingbean.theMethod"

In the method, if your condition is verified, you can set the attribute to "true".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM