最近我一直在尝试将我正在开发的这个应用程序从 JSF 1.2 升级到 JSF 2,但在此过程中我遇到了瓶颈,因为您可能已经知道 AjaxBehaviorEvent 对 JSF 来说是全新的,并且回到 JSF 1.2 并使用 RichFaces 3 我能够执行以下操作:
在支持 bean 中有一个方法的签名
public void onSomeEvent(ActionEvent evt){
//Process the event
}
我可以在以下两个位置调用此方法,如下所示 1-
<h:commandButton actionListener="#{bean.onSomeEvent}" value="Process Event"/>
2-
<h:commandButton value="Process Event" >
<a4j:support event="oncomplete" actionListener="#{bean.onSomeEvent}" />
</h:commandButton>
现在在 JSF 2 中有两种类型的事件,旧的 ActionEvent 和新的 AjaxBehaviorEvent,两者似乎不能互换使用,我的意思是如果我要将方法与 f:ajax 一起使用,那么它需要有 AjaxBehaviorEvent它的参数列表,如果我要将它与组件的普通 DHTML 事件一起使用,那么它需要在参数列表中有一个 ActionEvent。
我想知道是否有某种方法可以使用,例如,使用我在 JSF 2 中对两种类型的事件所做的事情。
谢谢大家
最佳答案
我确实按照@maple_shaft 的建议通过使用 EL 2.2 解决了这个问题,我所做的是从我没有使用它的方法中删除了 ActionEvent 参数。
关于java - JSF2 中的 AjaxBehaviorEvent 与 ActionEvent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11736186/