是否可以在另一个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"
。
嗯,答案就在我的问题中 - .-
<p:commandButton value="save" action="#{myBean.save}" oncomplete="$('#print').click();" />
<p:commandButton value="print" id="print" ajax="false" action="#{myBean.print}" />
保存表单,然后单击触发按钮2。
您可以使用p:remoteCommand
作为:
<p:remoteCommand name="callButton2" action="#{myBean.print}" />
然后在你的button-1
<p:commandButton value="save" action="#{myBean.save}
oncomplete="callButton2()" />
现在,如果按“保存”,则完成它将调用打印方法。
记住你应该在p:remoteCommand
里面有form
。