0

I have created some button dynamically and i wanted to know which button is clicked on the managed bean all the buttons go to the same method and i what to determine which one is clicked. This is how i created the button.

<ui:repeat var="o" value="#{postManagedBean.answer}" varStatus="status">
     <p:commandLink action="#{postManagedBean.add}" id="#{status.index}"/>
</ui:repeat>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
codeblue
  • 43
  • 6

1 Answers1

-1

Add the index as a parameter for the action.

<ui:repeat var="o" value="#{postManagedBean.answer}" varStatus="status">
     <p:commandLink action="#{postManagedBean.add(status.index)}" id="#{status.index}"/>
</ui:repeat>

This way you can access the index in the action method.

xacy
  • 21
  • 1
  • 2
  • 7