在p:dataExporter中更改p:graphicImage的导出值 [英] Change exported value of p:graphicImage in p:dataExporter

查看:380
本文介绍了在p:dataExporter中更改p:graphicImage的导出值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:



我以0和1字符串形式从数据库中获取虚假/真实值。



因为我想对我的用户很好:-)我的数据表中的输出不应该是零和一个。



所以我使用一个代表状态为零和一个的图形。



我这样做(在p:datatable内):

 < p:column width =50sortBy =#{report.arrived}> 
< f:facet name =header> Report?< / f:facet>
< p:graphicImage library =images
name =#{report.arrived} .gif/>
< / p:column>

所以,0.gif显示为false,而1.gif为true。



看起来像这样:





我从原点的dataexporter的问题是这个列将导出为


org.primefaces.component.graphicimage.GraphicImage@26bbdbd


有没有办法更改导出值?任何想法如何获得图形图像并导出价值?



感谢您的帮助!



规格:
JBoss 7.1
JSF 2.0
原始3.5



编辑:



解决了这个解决方案,thx到BalusC!



p:dataExporter不能识别p:cellEditor

解决方案

根据您真正报告的问题4013 自从PrimeFaces 3.5.25,4.0.9和5.0以来,数据出口商现在对< p:cellEditor> < h:图形图像>



如果< h:graphicImage> code> alt 属性将用于表示导出的值。额外的好处是,它迫使你使视觉障碍者更容易访问您的网站;)



例如

 < p:graphicImage ... alt =#{report.arrived =='0'?'否':'是'}/> 

顺便说一下,你应该更好地使用一个布尔值c $ c>或枚举而不是 int



另见:




I have the following problem:

I get false / true values from my database in form of „0" and „1" strings.

Because I want to be nice :-) to my users, the output in my datatable shouldn't be zeros and ones.

So I use a graphic which represents the states zero and one.

I do it like this (inside p:datatable):

<p:column width="50" sortBy="#{report.arrived}">
           <f:facet name="header">Report?</f:facet>
           <p:graphicImage library="images"
               name="#{report.arrived}.gif" />
</p:column>

So 0.gif is shown for false and 1.gif for true.

It looks like this:

My problem with the dataexporter from primefaces is that this column will be exported as

org.primefaces.component.graphicimage.GraphicImage@26bbdbd

Is there a way to change the exported value? Any ideas how I could get a graphical image and exporting the value?

I appreciate your help!

Specs: JBoss 7.1 JSF 2.0 Primefaces 3.5

EDIT:

Solved, smiliar to this solution, thx to BalusC !

p:dataExporter does not recognize p:cellEditor

解决方案

As per issue 4013, reported by yours truly, since PrimeFaces 3.5.25, 4.0.9 and 5.0 the data exporters have now additional support for <p:cellEditor> and <h:graphicImage>.

In case of <h:graphicImage>, the alt attribute will be used to represent the exported value. Additional bonus is, it forces you to make your website more accessible to the visually disabled ;)

E.g.

<p:graphicImage ... alt="#{report.arrived == '0' ? 'No' : 'Yes'}" />

By the way, you should here really better use a boolean or an enum instead of an int.

See also:

这篇关于在p:dataExporter中更改p:graphicImage的导出值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆