如何通过h:commandbutton actionListener传递一个Object和ActionEvent?

问题描述 投票:0回答:1

我可以将JSE页面中的ActionEvent传递给void clicked(ActionEvent event)的方法<h:commandButton ... actionListener="#{something.clicked}" ...>

我也可以通过void clicked(Object obj)将一个Object传递给<h:commandButton ... actionListener="#{something.clicked(Object obj)}" ...>方法

但是如何在一次调用void clicked(ActionEvent event, Object obj)这样的方法中传递两者?

jsf-2.2
1个回答
0
投票

我猜你在找

<f:setPropertyActionListener />

你把它放在commandButton或commandLink中:

<h:commandButton actionListener="#{something.clicked}">
    <f:setPropertyActionListener target="#{something.obj}" value="#{obj}"> 
</h:commandButton>

它在调用监听器之前用obj填充something.obj属性。

对于JSF 1.x,您可以使用MyFaces Tomahawk

<t:updateActionListener />

这也是一样的。

© www.soinside.com 2019 - 2024. All rights reserved.