PDA

View Full Version : CRTL + C triggers a reload of data in Combobox



andap
18 Jun 2012, 8:30 AM
Hello,

In our application we are using a search (autosuggest) combobox with pagination for the results. The extended class is the following:


public class AjaxPagingComboBox<T extends ModelData> extends ComboBox<T> {
public interface GetPagingDataCallback<T> {
void getData(String query, PagingLoadConfig loadConfig,
AsyncCallback<PagingLoadResult<T>> dataCallback);
}


public AjaxPagingComboBox(final String displayField, final int minChars,
final GetPagingDataCallback<T> getDataCallback) {


final RpcProxy<PagingLoadResult<T>> proxy = new RpcProxy<PagingLoadResult<T>>() {


@Override
protected void load(Object loadConfig,
final AsyncCallback<PagingLoadResult<T>> callback) {
final Map<String, Object> properties = ((PagingLoadConfig) loadConfig)
.getProperties();
getDataCallback.getData((String) properties.get("query"),
((PagingLoadConfig) loadConfig),
new AsyncCallback<PagingLoadResult<T>>() {
@Override
public void onSuccess(
final PagingLoadResult<T> result) {
callback.onSuccess(result);
}


@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);


}
});
}


};


ModelReader reader = new ModelReader();
final BasePagingLoader<PagingLoadResult<T>> loader = new BasePagingLoader<PagingLoadResult<T>>(
proxy, reader);
loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() {
public void handleEvent(LoadEvent be) {
be.<ModelData> getConfig().set("start",
be.<ModelData> getConfig().get("offset"));
}
});


setFieldLabel(displayField);
final ListStore<T> store = new ListStore<T>(loader);
setStore(store);
setHideTrigger(true);
setMinChars(minChars);
setUseQueryCache(false);
setPageSize(10);
}

However, if the user wants to copy and paste the current value entered in the combo and this field loses focus, a new search is triggered. We would like to disable this behaviour because of some validations we have on the field.

In conclusion, how can I disable a new search when someone uses CTRL + C on the field?

Thank you in advance