Primeface的remoteCommand - 有办法执行一次吗?

aby*_*lie 3 jsf primefaces remotecommand

Primefaces 3.5 JSF 2.1

\n\n

I\xc2\xb4m 使用 p:remoteCommand 执行异步命令并在页面加载后更新我的视图,但看起来在每次迭代结束时它会再次执行等等...

\n\n

这种行为正确吗?

\n\n

如何只执行一次p:remoteCommand?

\n\n

更新

\n\n

我已经检查过我的远程命令不在更新面板中,所以感谢您的回答,但已经可以了。我如何解决我的问题:

\n\n

我不知道为什么,但使用 Omnifaces 的 onloadScript ( http://showcase.omnifaces.org/components/onloadScript ) 来调用它被调用多次的 RemoteCommand 函数,但使用 $(document).ready ...仅一次。所以,我改变了它,现在就可以使用了。

\n

Aks*_*ert 5

如果您最终陷入无限循环之类的行为,您可能会将父组件更新到您的<p:remoteCommand>.

<h:form id="myform">
    <p:remoteCommand update="myform" actionListener="#{remoteCommandView.execute}" />
    ...
</h:form>
Run Code Online (Sandbox Code Playgroud)

将其放在您要更新的组件的外部/旁边,一切应该没问题。

<h:form id="newform">
<p:remoteCommand update="myform" actionListener="#{remoteCommandView.execute}" />
</h:form>
<h:form id="myform">
...
</h:form>
Run Code Online (Sandbox Code Playgroud)