I have a view (.xhtml) and that view contains a dataTable. Inside that dataTable there is one column named "Type" that correspond to the attribute "CTYPE". CTYPE stores three types of values: 'AB', 'BC' and 'CD'. I then have an Enum that translates those values into more adequate strings. Ex: 'AB' -> 'My String test 1', etc..., where 'AB' is the key and 'My String test 1' is the correspondent description (value). The column of the dataTable mentioned above ("Type") shows the description of every key, i.e., instead of 'AB' it shows 'My String test 1', and so on. That column is a sorteableColumn and has a sortKey='CTYPE' that sorts the column by Type. The problem is I want to sort the column by description and not by key. So, I want to sort by 'My String test 1', 'My String test 2'... instead of 'AB', 'BC'... In order to achieve that, my sortKey would have to have access to the Enum and translate the key into the correspondent description. However, I'm not managing to do it.
My .xhtml:
<p:column>
<f:facet name="header">
<ccomponent:sortableColumn model="#{typeSearchM}"
controller="#{typeSearchC}"
label="#{msg['labels.types.type_method']}"
sortKey="CTYPE" />
</f:facet>
<h:outputText value="#{msg[typeDTO.getTypesMethod()]}" />
</p:column>
My TypeDTO.java:
public String getTypesMethod() {
return DestinationTypeDomain.getDescByKey(typeData.getCType());
}
where DestinationTypeDomain is the enum that translates the key to the description. What I'd like to that is change my sortKey to something like:
sortKey="#{DestinationExpeditionDomain.getDescByKey(typeDTO.destinationDesc)}"