使用Primefaces编辑器的Primefaces数据导出器

使用Primefaces编辑器的Primefaces数据导出器,primefaces,Primefaces,是否可以使用primefaces的数据导出器将编辑器数据导出为pdf 我尝试了以下代码,但不起作用 <p:editor value="#{mailBean.mail}" id="editor"> </p:editor> <p:commandLink> <p:graphicImage value="/images/pdf.gif" /> <p:dataExporter type="pdf" target="edi

是否可以使用primefaces的数据导出器将编辑器数据导出为pdf

我尝试了以下代码,但不起作用

 <p:editor value="#{mailBean.mail}" id="editor">

    </p:editor>

    <p:commandLink>
    <p:graphicImage value="/images/pdf.gif" /> 
<p:dataExporter type="pdf" target="editor" fileName="files" pageOnly="true"/> 
    </p:commandLink>

不,不是

从用户指南:

DataExporter可以方便地将使用Primefaces数据表列出的数据导出为各种格式 例如excel、pdf、csv和xml

更多信息请参见《用户手册》

目标必须 指向PrimeFaces数据表

编辑


您可以尝试的是:在您的项目中集成编辑器并查看此线程,这里有一个直接链接

Data exporter publisher按钮不能是ajax,目标值应该是一个datatable,您还需要itext 2.1.7可选DataExporter(PDF)*apache poi 3.7可选DataExporter*库(Excel)

即使他们是好的,数据导出器还不稳定,这取决于您的数据表。例如,当您将动态列与列组一起使用时,它无法导出数据

我更喜欢使用itext库导出您自己的文档,它也更灵活


祝你好运

如果目标必须指向PrimeFaces数据表,那么下面的代码是如何实现的 这是来自primeface网站。()


函数exportChart(){
//导出图像
$('#output').empty().append(PF('chart').exportAsImage());
//显示对话框
PF('dlg').show();
}

这里的源文件是一个图表,使用函数exportChart()将导出的数据作为图像。这意味着我们可以导出任何数据,而不仅仅是primeface数据表

谢谢丹尼尔的快速回复。
    <p:lineChart value="#{chartBean.linearModel}" legendPosition="e" zoom="true"  
                         title="Linear Chart" minY="0" maxY="10" style="width:500px;height:300px" widgetVar="chart"/>  

<p:commandButton type="button" value="Export" icon="ui-icon-extlink" onclick="exportChart()"/>  

<p:dialog widgetVar="dlg" showEffect="fade" modal="true" header="Chart as an Image">  
    <p:outputPanel id="output" layout="block" style="width:500px;height:300px"/>  
</p:dialog>  

function exportChart() {  
    //export image  
    $('#output').empty().append(PF('chart').exportAsImage());  

    //show the dialog  
    PF('dlg').show();  
}