optional
optional

Reputation: 3350

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?

Upvotes: 0

Views: 4277

Answers (2)

user3825550
user3825550

Reputation: 11

You also have to use update="<id>" in your button... so,for example, you would need <p:commandButton...update="thepanelid".../> <p:panel id="thepanelid"...

Upvotes: 1

JSFDude
JSFDude

Reputation: 31

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".

Upvotes: 0

Related Questions