2
votes

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:

Screenshot

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

1
Solved, smiliar to this solution, thx to BalusC ! p:dataExporter does not recognize p:cellEditor98percentmonkey

1 Answers

2
votes

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: