Form and ComboBox question

I have the following Address object

can someone point me to an example of how to create a Form where it has a ComboBox with something like the State object (any object will do)?
I have no problems creating one where ComboBox has only a string, but can’t get it to work with an object.

Thank You

Peter

public class Address {

private String street;
private State state;

public State getState() {
    return state;
}

public void setState(State state) {
    this.state = state;
}

public String getStreet() {
    return street;
}

public void setStreet(String street) {
    this.street = street;
}

}

public class State {

private String id;
private String name;

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

}

Create any Collection using the State object and then, use it as the parameter for ComboBox.

Crude Example:

List<State> states = new List<State>();
State state = new State();
state.setName("....");
states.add(state);
state = new State();
...
states.add(state);
...
...
ComboBox cb = new ComboBox("States", states);

Make sure that State class has a toString() method:

public String toString() {
    return name;
}

I have the following Class (Address) which has an object (State) as one of it’s properties,

I have the following code:

Address address = new Address();
State state = new State(“ST”, “MyState”);
address.setState(state);

BeanItem addressItem = new BeanItem(address);

On my form I have a ComboBox which contains a list of States,
When I execute setItemDataSource(addressItem);
all the Text fields on my form get the values from the BeanItem with exception of the DropDown box, it remains blank (although the dropdown box does retain its list and one of the items in the list does equal to the BeanItem).
I don’t know how to assign the value to the ComboBox when the item is not a string

How do I populate the value of the ComboBox when the BeanItem is an object?

public class Address {

private String street;
private State state;

public State getState() {
return state;
}

public void setState(State state) {
this.state = state;
}

public String getStreet() {
return street;
}

public void setStreet(String street) {
this.street = street;
}

}

public class State {

private String id;
private String name;

public State() {}
pubic State(String id, String name) {
this.id = id;
this.name = name;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public toString() {
return name;
}

}