1

I need same help, i want to show a button when i select an Item from a , this is my code:

<h:selectOneMenu value="#{managedBeanProjects.etat}">
<f:selectItems value="#{managedBeanProjects.statueOptions}">
</h:selectOneMenu>

I want to show this button, in default it will be disabled

<p:commandButton id="buttonStatue" value="ok" 
     update=":form1:growl :form1:pTest" icon="ui-icon-check" />

thanks.

Avinash Singh
  • 3,421
  • 2
  • 20
  • 21

1 Answers1

2

Just let the button's rendered attribute evaluate true when #{managedBeanProjects.etat} is not empty. You can use <f:ajax> to ajaxically update the HTML representation on change of the dropdown. Note that you should ajax-update the button's parent as it's not possible to ajax-update a component which is by itself never rendered in first place.

<h:selectOneMenu value="#{managedBeanProjects.etat}">
    <f:selectItems value="#{managedBeanProjects.statueOptions}">
    <f:ajax render="buttonStatueParent" />
</h:selectOneMenu>

<h:panelGroup id="buttonStatueParent">
    <p:commandButton id="buttonStatue" value="ok" 
        update=":form1:growl :form1:pTest" icon="ui-icon-check"
        rendered="#{not empty managedBeanProjects.etat}" />
</h:panelGroup>

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555