Bınd Boolean values to ComboBox

Hey guys,

I have a POJO whıch has gender value of customers as a Boolean. I have make a combobox ın a form which is data source is Customer type.
How can I make the combobox have “Male” and “Female” choices which are boolean values.

Thanks.

public class Customer implements Serializable {
public static final String QUERY_ALL = “Customer.queryAll”;
public static final String QUERY_BY_ID = “Customer.queryById”;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(length = 50, nullable = false)
private String name;
@Column(length = 50, nullable = false)
private String surname;
@Column(nullable = false)
[u]


private Boolean gender;

[/u]

   //getters and setters....

}

Hi Yakup,

this should work:


ComboBox box= new ComboBox();
box.addContainerProperty("displayName", String.class, "");
box.addItem(true).getItemProperty("displayName").setValue("Male");
box.addItem(false).getItemProperty("displayName").setValue("Female");
box.setItemCaptionPropertyId("displayName");
box.setNullSelectionAllowed(false);

Add a container-property for the displayname and use true and false as item-Ids.

Or this way;


ComboBox box= new ComboBox();
box.addItem(true);
box.addItem(false);
box.setItemCaption(true, "Male");
box.setItemCaption(false, "Female");
box.setNullSelectionAllowed(false);

regard,
Pascal

thx man!