我们计划使用 PrimeFaces PrinterBehavior 组件来打印页面上的数据。但是在提交表单(包装打印机标签)时会抛出 NullPointerException;我们意识到这是因为 savaState() 和 restoreState() 方法没有被实现。
这是一个已知问题还是我们在这里遗漏了什么?
xhtml代码片段:
<h:commandButton id="printId" value="print" styleClass="printButton">
<p:printer target="useListDatatable" />
</h:commandButton>
<p:dataTable width="100%" id="useListDatatable">
</p:dataTable>
堆栈跟踪:
Caused by: java.lang.NullPointerException: expr
at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:698)
at org.primefaces.component.behavior.printer.PrinterBehavior.getScript(PrinterBehavior.java:46)
at org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils._appendClientBehaviourScript(HtmlRendererUtils.java:2004)
at org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils.getClientBehaviorScript(HtmlRendererUtils.java:1983)
at org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils.buildBehaviorChain(HtmlRendererUtils.java:2154)
at org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils.buildBehaviorChain(HtmlRendererUtils.java:2119)
at org.apache.myfaces.shared.renderkit.html.HtmlButtonRendererBase.buildBehaviorizedOnClick(HtmlButtonRendererBase.java:393)
at org.apache.myfaces.shared.renderkit.html.HtmlButtonRendererBase.encodeEnd(HtmlButtonRendererBase.java:209)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:657)
at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:537)