执行backbean方法并在JSF+;素面

执行backbean方法并在JSF+;素面,jsf,primefaces,Jsf,Primefaces,我正在尝试使用JSF和PrimeFaces开发一个计费应用程序。基本功能要求向账单中添加多个项目,并在账单完成后单击“更新”按钮。打印的票据必须包括在backing bean settleBill方法末尾生成的BillId等详细信息。它需要在一页中完成,以便打印后,应用程序可以准备新的账单 我开发了如下,但是打印和执行该方法并没有像预期的那样发生 <p:commandButton value="Settle" action="#{billController.saveSelected()

我正在尝试使用JSF和PrimeFaces开发一个计费应用程序。基本功能要求向账单中添加多个项目,并在账单完成后单击“更新”按钮。打印的票据必须包括在backing bean settleBill方法末尾生成的BillId等详细信息。它需要在一页中完成,以便打印后,应用程序可以准备新的账单

我开发了如下,但是打印和执行该方法并没有像预期的那样发生

 <p:commandButton value="Settle" action="#{billController.saveSelected()}" ajax="false" >
     <p:printer target="pDetails"  /> 
 </p:commandButton>

当我不使用Ajax时,打印部分是可以的,但不会执行操作。与Ajax一起使用时,会执行命令,但打印不起作用。我使用了一个action listner而不是action,结果仍然一样

<p:commandButton value="Settle" actionListener="#{billController.settleBill}" ajax="false" >
    <p:printer target="pDetails"  /> 
</p:commandButton>

如何在获得最终值(如Bill Id)的打印输出的同时执行backing bean方法,该值是在backing bean方法完全执行后生成的。我想在单个页面中实现它,以便在每次账单之后,屏幕可以准备好下一次账单


提前感谢。

当您在不使用Ajax的情况下使用时,要进行打印以及操作,您必须使用以下代码:

<p:commandButton value="Settle" actionListener="#{billController.settleBill}">
<f:ajax execute="@this"/>
    <p:printer target="pDetails"  /> 
  </p:commandButton>

当您在没有Ajax的情况下使用时,要使打印和操作正常工作,您必须使用以下代码:

<p:commandButton value="Settle" actionListener="#{billController.settleBill}">
<f:ajax execute="@this"/>
    <p:printer target="pDetails"  /> 
  </p:commandButton>

公共无效测试(ActionEvent ActionEvent){}



公共无效测试(ActionEvent ActionEvent){}

你能解释一下这个答案吗?只懂代码的答案可能很难理解。你能解释一下这个答案吗?只懂代码的答案可能很难理解。
<p:remoteCommand name="rc"  actionListener="#{movimentoBean.test}" />

           <p:commandButton value="Imprimir" type="button" 
              icon="ui-icon-print" onclick="rc();PF('visDialog').hide()"
              style="display:block;margin-bottom: 20px">
              <p:printer target=":formMovimentos:etiqueta" />
           </p:commandButton>