目前我在我的报告项目中使用 jsf2、primefaces 4 和 omnifaces。
我有如下的jsf表单:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" >
<ui:composition template="/templates/reportLayout.xhtml">
<ui:define name="centerContent">
<h:form>
Parameter 1: <p:inputText />
Parameter 2: <p:inputText />
Output Type:
<p:selectOneMenu>
<f:selectItem itemValue="html" />
<f:selectItem itemValue="pdf" />
</p:selectOneMenu>
<hr/>
<p:commandButton value="Generate Report"
action="#{reportBean.generate}" />
</h:form>
<p:outputPanel id="output">
<p:lightBox iframe="true">
</p:lightBox>
</p:outputPanel>
</ui:define>
</ui:composition>
</html>
根据参数,reportBean.generate 方法将从 reportBean 生成 pdf 响应或 html 响应,如下所示。
> res27: String = application/pdf
> res28: Array[Byte] = Array(37, 80, 68, 70, 45, 49, 46, 54, 13, 10, 57, 32, 48, 3
2, 111, 98, 106, 13, 10, 60, 60, 47, 84, 121, 112, 101, 47, 88, 79, 98, 106, 1
01, 99, 116, 47, 83, 117, 98, 116, 121, 112, 101, 47, 70, 111, 114, 109, 47, 7
, 119, 51, -30,...
如何在输出面板中显示响应?