Seitaridis
Seitaridis

Reputation: 4529

Send component value and another parameter to a listener

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?

Upvotes: 3

Views: 5101

Answers (1)

BalusC
BalusC

Reputation: 1108632

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)}" />

Upvotes: 7

Related Questions