0

我有一个a4j:outputPanel。我通过单击页面中的另一个位置来重新呈现它,并且我想在重新呈现时触发一个动作outputPanel

是否有 onrerender 事件或什么?我已经尝试过,我已经搜索过,但我不能做我想做的事。我知道我可以使用 oncomplete 事件来触发重新渲染操作,但这就是我不想做的事情。

无论如何,你有什么想法吗?我不需要确切的解决方案,只是想法可以帮助我找到解决方法。

编辑:对不起,我要触发的动作是 js 动作。

4

3 回答 3

1

尝试放置

<f:event listener="#{myBean.myAction}" type="preRenderComponent"></f:event>

在你的outputPanel...

public void myAction(ComponentSystemEvent componentSystemEvent) {  
   //some code goes here...
}  

如果你想从你的托管 bean 方法调用 js 代码,你可以使用Primefaces - RequestContext

public void myAction(ComponentSystemEvent componentSystemEvent) {  
    RequestContext requestContext = RequestContext.getCurrentInstance();  
    requestContext.execute("alert('wow')");
}
于 2013-02-26T12:00:01.027 回答
0

如果您确定动作会重新呈现组件,那么为什么不将其添加到动作本身中。您还可以使用 Daniel 建议的方法并从您的 Java 方法中添加 JavaScript 调用。Icefaces 带有一个 JavaScript 上下文类,我相信richfaces 也会有类似的东西。

于 2013-02-26T15:11:05.093 回答
0

Try the onbeforedomupdate of the <a4j:ajax/> component

<a4j:outputPanel>
   <a4j:ajax onbeforedomupdate="yourJs();"/>
</a4j:outputPanel>
于 2013-02-26T17:46:09.647 回答