Jsf Primefaces,触发命令按钮单击完成

Jsf Primefaces,触发命令按钮单击完成,jsf,primefaces,Jsf,Primefaces,是否可以在另一个commandButton的oncomplete属性上触发单击commandButton 像这样: <p:commandButton value="save" action="#{myBean.save} oncomplete="trigger button2" /> <p:commandButton value="print" ajax="false" action="#{myBean.print}" widgetVar="button2" /> 第二

是否可以在另一个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:remoteCommand用作:

现在,如果您按Save,完成后将调用print方法


请记住,表单中应该有p:remoteCommand

答案在我的问题中--

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

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

我认为p:remoteCommand可以正确调用ajax吗?我需要在我的第二个命令按钮中添加一个非ajax帖子:/exporting一个你在问题中没有提到的PDFy。尽可能多地提供信息。编辑我的问题,第二个按钮的属性是ajax=falseThx-Makky,这是一个很好的技巧,可以在服务器端获得一个后回调函数,以便让primefaces完成其过程,并且只在之后应用渲染完成。你刚刚救了我一天!
<p:commandButton value="save" action="#{myBean.save} 
 oncomplete="callButton2()" />
<p:commandButton value="save" action="#{myBean.save}" oncomplete="$('#print').click();" />
<p:commandButton value="print" id="print" ajax="false" action="#{myBean.print}" />