2

I have a value which is stored as an enum that I want to display in a Primefaces datatable with a different value displayed per locale.

This is what I currently have in the data table:

<p:dataTable id="DtSources" var="source" value="#{sourceView.sources}" selection="#{sourceView.selectedSource}" selectionMode="single" scrollable="true" resizableColumns="true" rowKey="#{source.id}">
 <f:facet name="header">Sources</f:facet>
 
 <p:column headerText="Type">
  <h:outputText value="#{source.type}" /> <!-- This is what I'm trying to fix -->
 </p:column>

</p:dataTable>

The problem is the value in #{source.type}. It should display as "Collection" or "Examples" in English and something like "Menge" or "Beispiele" in German and it currently just shows an ugly string representation of the enum like COLLECTION or EXAMPLES.

There has to be a nice way to do this, but I haven't figured it out yet. Also, I don't want to add the logic to the model for obvious reasons.

KG6ZVP
  • 3,610
  • 4
  • 26
  • 45
  • No, it fails in this case to, but you can undo my edits, 1 button click in the edit history. The fact that you need it in a datatable does not make the issue related to/caused by the datatable – Kukeltje Aug 05 '17 at 22:28
  • The relation to the datatable is just to do with the for-each type iteration. Would you be willing to write an answer to explain how you would solve this problem? – KG6ZVP Aug 05 '17 at 22:32
  • I twice pointed you in the right direction. First by editing/narrowing down the problem/editing the tagging and even more in my last comment. And he SHOUTING did mot help either. Besides that, it is 0:35 here, bed time – Kukeltje Aug 05 '17 at 22:35
  • Post "jsf i18n enum" in google and read an 10-25 upvoted Q/A in stackoverflow – Kukeltje Aug 05 '17 at 22:38
  • Your tagging and assumption of where the problem is is still wrong, it is a plain jsf issue. – Kukeltje Aug 06 '17 at 14:17

0 Answers0