DataTableXMLExporter: How to generate tag names which ignore the current locale?

UI Components for JSF
Post Reply
stolp
Posts: 127
Joined: 21 Aug 2018, 16:05

23 Oct 2021, 16:34

In my mullti-lingual application, I like to export my tables to XML output.

The current implementation of DataTableXMLExporter derives tag names in the XML output from the corresponding column header value, which change according to the current locale setting used in the application.

This leads to different XML element names in the output for different locale settings, which really makes no sense at all.

How can I best circumvent this when extending DataTableXMLExporter? I think I need to override Exporter.exportValue(...)
for this, but I am lost on how to force a locale to use there.

Would it make sense to at least pin down the locale used for element tags by an option to DataTableXMLExporter?

The application is currently using PrimeFaces 10 and PrimeFaces 11 soon.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

24 Oct 2021, 16:59

There is a custom `exportHeaderValue` property on the column Couldn't you just always leave that in English or whatever you wanted the export header to be? ITs not displayed in the UI its purely to control this for exporting.

Code: Select all

<p:column headerText="Zeit" exportHeaderValue="Time" ...
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

stolp
Posts: 127
Joined: 21 Aug 2018, 16:05

24 Oct 2021, 19:32

Thanks for pointing out the usage of exportHeaderValue.

There is one severe problem with this approach, as it will influence the behavior of other exporters as well.

So when I set a fixed language exportHeaderValue string for the XMLTableExporter it will also appear for PDF, XSLX and others, so the user will stumble about column headers in a wrong language. As you might have guessed, we offer using several export formats for our tables as well.

So whatever the solution is, it has to be on a per-Exporter basis, just targeting the XML export.

In what I see from the exporter code, header string value generation is done in Exporter.exportValue(). By overriding this method in my custom XMLTableExporter I may patch in the desired behavior. I am just out of ideas on how to continue from there.

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

24 Oct 2021, 20:25

You are correct this will affect all exporters. I would submit an enhancement ticket on GitHub.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 27 guests