Hi All,
I’m trying to understand the use of getContainerProperty.
I assumed that it was used to get an an item in the underlying data source. I am using a BeanItemContainer with a list of state objects. The state looks like:
public class StateMaster {
private String statecode;
private String statename;
// setters and getters
}
I get these out of the database into a List and do an .addAll into the BeanItemContainer.
In the UI, I add the BeanItemContainer into a combobox.
ComboBox states = new ComboBox("State");
states.setContainerDataSource(addressDataService.getStateList());
states.setItemCaptionMode(Select.ITEM_CAPTION_MODE_PROPERTY);
states.setItemCaptionPropertyId("statename");
All of the above works fine. I get the stateNames displayed correctly, etc. Based on information gethered elsewhere, I have a state code. I want to show the state selected in the text portion of the combo box.
So, I am trying go get a hold of the state object in the data source for the combobox so that I can make it selected and the name of the state shows in the combo box.
I am trying:
StateMaster sm = states.getContainerProperty("CA","statecode");
The above ALWAYS returns null. I am guessing I don’t understand how to use that method.
So, what I am trying to do is:
- locate the object with a statecode = “CA” in the combo box data source
- show the selected statename (“California”) in the text field of the combo box (i.e. make it the selected state).
Any help and clarification would be appreciated.
Tom