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