Title: Using converter in JavaServer Faces
Tags: jsf;converter;label
Question: I have that converter:

```public class PollConverter implements Converter {

    private static PollanswersDao pollsDao = new PollanswersDao();

    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return pollsDao.read(Long.parseLong(value));
    }

    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return String.valueOf(((PollanswersEntity)value).getId());
    }
}
```

In faces-config.xml:

```<converter&gt;
    <converter-id&gt;PollsConverter</converter-id&gt;
    <converter-class&gt;org.test.majas.converters.PollConverter</converter-class&gt;
</converter&gt;
```

So, I can unique identify poll only by ID. Ok I use this converter:

```<h:form&gt;
    <h:selectOneRadio layout="pageDirection" value="#{votesBean.answer}"&gt;
        <f:converter converterId="PollsConverter"/&gt;
        <f:selectItems value="#{pollsBean.selectItems}" var="item" itemLabel="#{item.value.title}" /&gt;
    </h:selectOneRadio&gt;
    <h:messages/&gt;
    <h:commandButton value="#{msgs.vote}" action="#{votesBean.addVote}"/&gt;
</h:form&gt;
```

But this itemLabel="#{item.value.title}" not working. My selectItems itemlabels are ID values... How can I show itemLabels as objects "title" fields. 

PollsBean:

```@Named
@SessionScoped
public class PollsBean implements Serializable {
    ...

    private List<SelectItem&gt; selectItems;

    ...

    public List<SelectItem&gt; getSelectItems() {
        return selectItems;
    }

    public void setSelectItems(List<SelectItem&gt; selectItems) {
        this.selectItems = selectItems;
    }

...

}
```

Thanks.

Comment: Not working - displayed items ID, without this attribute items ID are displayed too. I have added PollsBean structure to question.

Comment: Select item is javax.faces.model.SelectItem :)

Comment: Yes value is object of a class with title field.

Comment: Showed item ID (from converter getAsString)

Comment: _"Not working"_ means nothing is displayed or a thrown exception ?  
And how does `PollsBean`'s structure look like ?

Comment: What's the purpose of using this predefined class as an ordinary class, as object in the code ? Does it contain `Value` composite class which has `title` as a field ?

Comment: What's showed instead of what is desired to be ?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:03/13/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<jsf><converter><label>', 'Title': 'Using converter in JavaServer Faces', 'ViewCount': 51, 'id': 22372521, 'user_AboutMe': None, 'user_AccountId': 3310005.0, 'user_DisplayName': 'user2783755', 'user_Reputation': 568.0, 'user_Views': 76.0, 'user_id': 2783755.0}}