0

I have a list of orders in a table like this:

---------------------------------------------------
ORDERXY                        APPRVOVE     DECLINE
---------------------------------------------------
ORDERXYZ                       APPRVOVE     DECLINE

This "table" is created in a repeat element iterationg over List.

My question is what is the most clean and elegant way to know in the submit function triggered by a button on the table which order was decided on?

Thanks for your help!

Curunir
  • 1,186
  • 2
  • 13
  • 30

1 Answers1

0

Set the selected object into a bean variable using a setPropertyActionListener when either the approve or decline button is selected and your modal is shown.

E.g.

<ui:repeat value="#{bean.orders}" var="order">
    <ui:remove>other table columns</ui:remove>
    <h:commandButton id="approveButton">
        <f:setPropertyActionListener target="#{bean.selectedOrder}" value="#{order}" />
    </h:commandButton>
</ui:repeat>

in combination with bean properties

private List<Order> list;
private Order selectedOrder;
Rung Ip
  • 81
  • 4
  • How and where is the modal shown? And why do you use `p:datatable` instead of a `ui:repeat` as stated in the question... cheers – Kukeltje Sep 23 '17 at 07:16
  • Good catch, I used the wrong tag, but the core idea of setting the selected object into the bean is the same regardless of how OP structures the repeating content or the tag they use to do so. I don't believe how the modal is shown is relevant to the core question (how to determine which order object was selected), but i would assume there is a js associated with the button that shows the modal. – Rung Ip Sep 23 '17 at 10:02
  • Hi you know how to do this in xpage by any chance? – Curunir Sep 25 '17 at 20:08