1 Reply Latest reply on Jul 29, 2009 2:26 PM by Philip Murphy

    Custom Converter displaying non-id value

    Philip Murphy Newbie

      Is it possible to have a converter display some non-id value of an entity?

      I need to display a fraction in an edit field that is represented as a separate numerator and denominator back in the entity.

      <h:inputText value="#{myEntity}" converter="fractionConverter">
      MyEntity {
          Integer num;
          Integer den;
      public class FractionConverter implements javax.faces.convert.Converter {
      public String getAsString(FacesContext ctx, UIComponent component, Object o) {  
          MyEntity myEntity = (MyEntity) o;
          return myEntity.getNum() + "/" + myEntity.getDen();
      public Object getAsObject(FacesContext context, UIComponent component, String value) {
       'value' is some fraction, so there is no way to find out what myEntity I should use???? I have no identity key for the entity.