3

I have a panel grid with various checkboxes. A checkbox is associated with a certain mask. When the checkbox is pressed, the value of the checkbox(checked/unckecked) and a mask parameter specific to that checkbox should be passed to a listener.

<p:selectBooleanCheckbox value="#{options.mustChangePasswordMask}">
    <p:ajax listener="#{options.selectionChanged}" /> 
</p:selectBooleanCheckbox>

<p:selectBooleanCheckbox value="#{options.mustChangePasswordMask}">
    <p:ajax listener="#{options.selectionChanged('MASK_1')}" /> 
</p:selectBooleanCheckbox>

Both these code fragments do only half of the job that I want. I want to use the listener in all the checkboxes so I can't use the mustChangePasswordMask property inside the listener. Is it possible to send the checkbox value as a parameter to the listener or in another way accessible to the listener?

Seitaridis
  • 4,459
  • 9
  • 53
  • 85

1 Answers1

7

The current component is in EL available as implicit variable #{component}. In input component this will be set with an instance of UIInput class which in turn has a getValue() method which returns the submitted, converted and validated value. So, this should do

<p:ajax listener="#{options.selectionChanged(component.value)}" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I want to use the same listener in all the checkboxes. I will update the question with this information. – Seitaridis Jun 27 '12 at 11:24
  • @BalusC can both the `event` and aditional parameters be provided? http://stackoverflow.com/questions/39143601/ I have a question on the subject – kidwon Aug 25 '16 at 11:10