private DropDownValueChanged valueChanged;
public EnumDropDown(final String currentValue,
final DropDownValueChanged valueChanged,
final DropDownData dropData) {
final Constants cs = GWT.create( Constants.class );
this.valueChanged = valueChanged;
addChangeListener( new ChangeListener() {
public void onChange(Widget w) {
valueChanged.valueChanged( getItemText( getSelectedIndex() ),
getValue( getSelectedIndex() ) );
}
} );
//if we have to do it lazy, we will hit up the server when the widget gets focus
if ( dropData.fixedList == null && dropData.queryExpression != null ) {
DeferredCommand.addCommand( new Command() {
public void execute() {
LoadingPopup.showMessage( cs.RefreshingList() );
RepositoryServiceFactory.getService().loadDropDownExpression( dropData.valuePairs,
dropData.queryExpression,
new GenericCallback() {
public void onSuccess(Object data) {
LoadingPopup.close();
String[] list = (String[]) data;
if ( list.length == 0 ) {
list = new String[]{cs.UnableToLoadList()};
}
fillDropDown( currentValue,
list );
}
public void onFailure(Throwable t) {
LoadingPopup.close();
//just do an empty drop down...
fillDropDown( currentValue,
new String[]{cs.UnableToLoadList()} );
}
} );
}
} );