Jsf 如何在primefaces中向预处理器发送参数
我已将PrimeFaces自定义数据导出器实现为:Jsf 如何在primefaces中向预处理器发送参数,jsf,primefaces,primefaces-extensions,Jsf,Primefaces,Primefaces Extensions,我已将PrimeFaces自定义数据导出器实现为: <p:commandLink id="pdf" ajax="false" rendered="#{documentProcessor.isPDFVisible}"> <p:graphicImage value="/res/img/pdf_icon.png" /> <f:setPropertyActionListener value="true" target="#{exporterControlle
<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.PreprepPDF
方法中发送参数?我找不到将参数传递给processor方法的解决方案,但我使用了actionListener和后处理器,它工作了!测试预处理器是否也起作用
<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>
只需通过
documentProcessor.prepreprocessPDF(param1,param2)
,如果您的方法接受。该方法是预处理PDF(对象文档)文档由primefaces发送,这就是为什么它被用作属性,如果我没有错的话,我尝试发送您提到的参数,但文档未发送。prepreprepPDF
不是您的自定义方法吗?它是标准方法。我不知道这是否可以接收参数。来源:好的,你的exporterController.customExporter
做什么?
public void downloadTypeGenerator(ActionEvent actionEvent) {
downloadType = (String) actionEvent.getComponent().getAttributes().get("type");
}
public void excelDownloadPostProcessor(Object document) {
if(downloadType != null && downloadType .equalsIgnoreCase("myValue")){
//action...
}
}