Primefaces,Trigger命令按钮单击oncomplete

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

是否可以在另一个commandButton的oncomplete属性上触发对commandButton的单击?

像这样 :

<p:commandButton value="save" action="#{myBean.save} oncomplete="trigger button2" />
<p:commandButton value="print" ajax="false" action="#{myBean.print}" widgetVar="button2" />

第二个按钮是属性ajax="false"

jsf primefaces
2个回答
5
投票

嗯,答案就在我的问题中 - .-

<p:commandButton value="save" action="#{myBean.save}" oncomplete="$('#print').click();" />
<p:commandButton value="print" id="print" ajax="false" action="#{myBean.print}" />

保存表单,然后单击触发按钮2。


4
投票

您可以使用p:remoteCommand作为:

<p:remoteCommand name="callButton2" action="#{myBean.print}" />

然后在你的button-1

<p:commandButton value="save" action="#{myBean.save} 
 oncomplete="callButton2()" />

现在,如果按“保存”,则完成它将调用打印方法。

记住你应该在p:remoteCommand里面有form

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