1

I am passing an object from richface datatable like:

<rich:column>
<a4j:commandLink
value="Transfer inside Group" 
actionListener="#{adminBean.init_machineTransferInsideGroup}"
reRender="transferInsideGroupMachinePanel"
oncomplete="#{rich:component('transferInsideGroupMachinePanel')}.show()">
    <f:setPropertyActionListener
            target="#{adminBean.machineToChange}"
        value="#{Machineassg3}" />
    </a4j:commandLink>
<rich:column>

What i am expecting from above code, when command link is clicked:

  1. assign object (Machineassg3) to bean's variable (adminBean.machineToChange)
  2. then invoking actionlistener (init_machineTransferInsideGroup)
  3. after that richmodal panel

But steps that are happening is :

  1. Invoking actionlistener (init_machineTransferInsideGroup)
  2. assign object (Machineassg3) to bean's variable (adminBean.machineToChange)
  3. after that richmodal panel

How to do expected steps (means assigning first and then invoking actionlistener)

Prince John Wesley
  • 62,492
  • 12
  • 87
  • 94
user811602
  • 1,314
  • 2
  • 17
  • 47

2 Answers2

3

You should do the business job in action instead of actionListener. The action listener is intented to hold self-contained logic to prepare/preprocess the real business action and/or to log something, not to do the business job.

So, replace

actionListener="#{adminBean.init_machineTransferInsideGroup}"

by

action="#{adminBean.init_machineTransferInsideGroup}"

and remove the ActionEvent argument from the init_machineTransferInsideGroup() method. The action will be invoked after all action listeners (also the <f:setPropertyActionListener> one) have done its job.

See also:

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

You could get the rows variable with a ValueExpression.

Lets say you have in the dataTable declaration the attribute var="machine", then in the managed bean's action method you could get like so

FacesContext fCtx = FacesContext.getCurrentInstance();
ELContext elCtx = fCtx.getELContext();
ExpressionFactory ef = fCtx.getApplication().getExpressionFactory();
ValueExpression ve = ef.createValueExpression(elCtx, "#{machine}", Machineassg3.class);
machineassg3 = (Machineassg3)ve.getValue(elCtx);

I don't know the actual class of the machineassg3 variable and so I just had it like Machineassg3.

I hope it helps.

Efthymis
  • 1,326
  • 11
  • 13