【发布时间】:2013-06-14 15:22:04
【问题描述】:
我使用 Primefaces 4-SNAPSHOT,我有一些带有 <h:graphicImage> 的数据表,我想导出到不同的文档中。
p:dataExporter does not recognize p:cellEditor 中描述的修复
BalusC 提供的它适用于 ExcelExporter,但不适用于 CSVExporter。
当我尝试创建文档时,我得到了 NPE。
我试图从 Extend-Class 中删除第一行代码,因为我没有 CellEditor-Elements。这类作品。它没有 NPE 总线,这给了我一个包含 graphicsImage 的 toString() 和 alt 值的文档。
扩展类是这样的:
public class ExtendedCSVExporter extends CSVExporter
{
@Override
protected String exportValue(FacesContext context, UIComponent component)
{
if (component instanceof HtmlGraphicImage)
{
return (String) component.getAttributes().get("alt");
}
else
{
return super.exportValue(context, component);
}
}
}
我把它称为引用主题中的描述
public void exportPDF(DataTable table, String filename) throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
Exporter exporter = new ExtendedCSVExporter();
exporter.export(context, table, filename, false, false, "UTF-8", null, null);
context.responseComplete();
}
表格的列如下所示:
<p:column sortBy="state">
<f:facet name="header">
<h:outputText value="State">
</f:facet>
<h:graphicImage id="stateImg" name="state.png" library="icons" value="#{bean.state} />
<p:tooltip for="stateImg" value="Allowed" showEffect="fade" hideEffect="fade" />
</p:column>
对于 Excel 导出,这可以正常工作,并且为图像获取的值是工具提示的值,因为图形图像没有 alt 值。 但这不适用于 CSV 文件
我在 pageOnly 的文档中得到的是: "javax.faces.component.html.HtmlGraphicImage@23e645d8AltText"
对于整个表,我得到一个 NPE
有什么建议可以解决这个问题吗?
【问题讨论】:
标签: jsf jsf-2 primefaces datatable data-export