I’m sitting at the moment on a legacy system. I’ve got some domain objects which are holding only the key of some entities, now I was wondering what would be the best approach to display the value of the entity instead of the given key.
Could this be done by a converter for the <h:outputText /> tag?
E.g.
DomainObject
public class DomainObject {
private String keyOfEntityA;
// getter/setter
}
EntityA
public class EntityA {
private String key;
private String value;
// getter / setter
}
JSF
<h:outputText value="#{controller.domainObject.keyOfEntityA}" />
I don’t want to show the key in this case, I want the object and the value property should be shown.
Is there an elegant way to achieve this or do I have to extend my DomainObject by a wrapper class, which provides the needed objects?
Either replace
EntityAby aMap<String, String>so that you can useor get hold of them all in a
Map<String, EntityA>withEntityA‘s key as map key so that you can doI have the impression that
EntityAshould really have been aMap<String, String>from the beginning on or ajava.util.Propertiesobject if they hold applicationwide configuration settings, or perhaps aResourceBundlewith a bunch of properties files if they represent localized content.