74369

Change exported value of p:graphicImage in p:dataExporter

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:

<img src="https://i.stack.imgur.com/9nW3u.png" alt="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

<strong>EDIT:</strong>

Solved, smiliar to this solution, thx to BalusC !

p:dataExporter does not recognize p:cellEditor

Answer1:

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:

Recommend

  • When I use o:graphicImage, the image is not displayed
  • Cancel button doesn't work in case of validation error
  • create dynamic Confirm dialog in jsf
  • Why primefaces media dynamic doesn't work in view scope?
  • Similar function in C++ to Python's strip()?
  • CGAL: How to efficiently calculate the area of facets of a polyhedron?
  • How to select all in PrimeFaces TreeTable?
  • SOLR - Querying Facets, return N results per Facet
  • https in htaccess and order of rules (using Expression Engine)
  • Adding new column to DataFrame with values dependent on index ref
  • Safari PHP form submission -file upload hangs
  • How to get a table cell value using jQuery
  • PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea
  • AWS-SES: Handling Bounces for Invalid ISPs
  • How to create two column output from a single column
  • Is it possible to define rest argument in OCaml?
  • How can I get the choice “H2” back in the H2 consol?
  • Python ImageIO Gif Set Delay Between Frames
  • Approximate Order-Preserving Huffman Code
  • saving file generated by TCPDF
  • How to view images from protected folder with php?
  • Textfile Structure (tables)
  • java inputstream
  • HTTP/2 streams vs HTTP/1.1 connections
  • Combining SpatialPolygonsDataFrame of two neighbour countries
  • Syntax for setting draggablecursor property in google maps api
  • Does CUDA 5 support STL or THRUST inside the device code?
  • How to extract text from Word files using C#?
  • vba code to select only visible cells in specific column except heading
  • Why winpcap requires both .lib and .dll to run?
  • GridView Sorting works once only
  • Numpy divide by zero. Why?
  • How to get icons for entities from eclipse?
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • reshape alternating columns in less time and using less memory
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Converting MP3 duration time
  • Conditional In-Line CSS for IE and Others?