PDA

View Full Version : GXT 4.0 ComboBox question



BKFS
30 Dec 2015, 11:15 AM
I am using GXT 4.0 and am just trying to set up a ComboBox. Let's say that my comboBox will contain States such as AL for the value and Alabama for the label. I want to display Alabama (aka the label) in the dropdown of the ComboBox. I get nothing with the below code - the list is empty. However, if I make the key in the LabelValuePairProperties label (instead of value) and make value (instead of label) as the LabelProvider, I will get state abbreviations in the dropdown list. This make NO SENSE. Please explain to me what I am doing wrong. Thank you.

public interface LabelValuePairProperties extends PropertyAccess<LabelValuePair>

{
// The property is defined as 'key()' but matches up to the bean class variable 'value'

@Path("value")

ModelKeyProvider<LabelValuePair> key();

@Path("label")

LabelProvider<LabelValuePair> labelLabel();

ValueProvider<LabelValuePair, String> label();

}



public class LabelValuePair implements Serializable

{
private static final long serialVersionUID = xxxxx;

private String value;

private String label;


public LabelValuePair(String label, String value)
// example: label = "Open" value = 'O"

{

setLabel(label);
setValue(value);

}

public String getValue() {

return value;

}

public void setValue(String value) {

this.value = value;

}

public String getLabel() {
return label;
}

public void setLabel(String label) {

this.label = label;

}
+++++

LabelValuePairProperties properties = GWT.create(LabelValuePairProperties.class);

ListStore<LabelValuePair> store = new ListStore<LabelValuePair>(properties.key());

ComboBox<LabelValuePair> stateListBox = new ComboBox<LabelValuePair>(store, properties.labelLabel());