Display two or more properties at ComboBox ?

I’m trying display two properties at a ComboBox. I tried
setItemCaptionPropertyId()
but this displays only nome and I want to display attribute
nome
and
sobreNome
or more properties.

I’m trying this.

[code]
//jpacontainer aluno private CustomJPAContainer dsAluno = new CustomJPAContainer(Aluno.class);

//combobox aluno ComboBox cbxAluno = (ComboBox)field;
cbxAluno.setItemCaptionMode(ItemCaptionMode.PROPERTY);
cbxAluno.setConverter(new SingleSelectConverter(cbxAluno));
bxAluno.setImmediate(true); cbxAluno.setContainerDataSource(dsAluno);
cbxAluno.setItemCaptionPropertyId(“nome”);
cbxAluno.setItemCaptionPropertyId(“sobreNome”);
cbxAluno.setWidth(“10cm”);
cbxAluno.addValueChangeListener(this);
tabAluno.addComponent(cbxAluno);

//bean
@Entity
public class Aluno implements Serializable{
private static final long serialVersionUID = 1L;

@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;

@NotNull @NotEmpty @Size(min=3, max=50)
private String nome;

@NotNull @NotEmpty @Size(min=3, max=50)
private String sobreNome;
//gets sets
}
[/code]How to I do that ?

You can’t, since the CB only displays one property at a time. You need to set the caption manually for each item with ComboBox.setItemCaption(itemId, caption).

I’m not sure it will work with the JPAContainer, but you could try to create a new getter method in your bean that provides the caption (something like getDisplayCaption) and call setItemCaptionPropertyId(“displayCaption”). You don’t need a field in the bean, getter should enough. For reference, that would work with a BeanItemContainer.

yep dude…I did your suggestion.

I did this

@Transient
private String caption;

public String getCaption(){
   caption = nome + " " + sobreNome;
   return caption;
}

cbxAluno.setItemCaptionPropertyId("caption");

And now works.

Thanks a lot !