我已将PrimeFaces自定义数据导出器实现为:
<p:commandLink id="pdf" ajax="false" rendered="#{documentProcessor.isPDFVisible}">
<p:graphicImage value="/res/img/pdf_icon.png" />
<f:setPropertyActionListener value="true" target="#{exporterController.customExporter}" />
<pe:exporter preProcessor="#{documentProcessor.preProcessPDF}" type="pdf" target="compListTable" fileName="File_PDF" />
</p:commandLink>
请指出我如何以documentProcessor.preProcessPDF
方法发送参数?
答案 0 :(得分:0)
我找不到将参数传递给处理器方法的解决方案,但是我使用了actionListener和postprocessor,它起作用了!测试预处理器是否也可以工作。
<p:commandLink immediate="true" ajax="false"
actionListener="#{documentProcessor.downloadTypeGenerator}">
<f:attribute name="type" value="#{downloadType}" />
<p:graphicImage name="icons/excel_icon.png" library="img" width="24" />
<p:dataExporter type="xls" target="#{target}" fileName="#{fileName}"
postProcessor="#{documentProcessor.excelDownloadPostProcessor}" />
</p:commandLink>
后端: (downloadType是全局变量。)
public void downloadTypeGenerator(ActionEvent actionEvent) {
downloadType = (String) actionEvent.getComponent().getAttributes().get("type");
}
public void excelDownloadPostProcessor(Object document) {
if(downloadType != null && downloadType .equalsIgnoreCase("myValue")){
//action...
}
}