如何将对象从 richface 数据表传递到动作监听器
我从 richface 数据表中传递一个对象,如下所示:
<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>
单击命令链接时,我对上面的代码有何期望:
- 将对象(Machineassg3)分配给 bean 的变量(adminBean.machineToChange),
- 调用 actionlistener(init_machineTransferInsideGroup)
- 然后在 richmodal 面板之后
但是步骤正在发生的是:
- 调用actionlistener(init_machineTransferInsideGroup)
- 将对象(Machineassg3)分配给bean的变量(adminBean.machineToChange)
- 在 richmodal 面板之后
如何执行预期步骤(意味着首先分配然后调用动作侦听器)
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:
- assign object (Machineassg3) to bean's variable (adminBean.machineToChange)
- then invoking actionlistener (init_machineTransferInsideGroup)
- after that richmodal panel
But steps that are happening is :
- Invoking actionlistener (init_machineTransferInsideGroup)
- assign object (Machineassg3) to bean's variable (adminBean.machineToChange)
- after that richmodal panel
How to do expected steps (means assigning first and then invoking actionlistener)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在
action
而不是actionListener
中完成业务工作。操作监听器旨在保存独立的逻辑来准备/预处理真正的业务操作和/或记录某些内容,而不是执行业务工作。因此,将
替换为
ActionEvent
参数init_machineTransferInsideGroup()
方法并将其从init_machineTransferInsideGroup()
方法中删除。该操作将在所有操作侦听器(还有
侦听器)完成其工作后被调用。另请参阅:
You should do the business job in
action
instead ofactionListener
. 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
by
and remove the
ActionEvent
argument from theinit_machineTransferInsideGroup()
method. The action will be invoked after all action listeners (also the<f:setPropertyActionListener>
one) have done its job.See also:
您可以使用 ValueExpression 获取 rows 变量。
假设您在 dataTable 声明中有属性
var="machine"
,那么在托管 bean 的操作方法中您可能会得到这样的结果,所以我不知道
machineassg3< 的实际类/code> 变量,所以我就像
Machineassg3
一样。我希望它有帮助。
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 soI don't know the actual class of the
machineassg3
variable and so I just had it likeMachineassg3
.I hope it helps.