PDA

View Full Version : ComboBox after correct RPC no data in widget



estefan.civera
14 Jun 2011, 4:11 AM
Hi all,

I'm tring to populate combobox via RPC, but when I click on this widget I'm only able to get data from server side but not add into combobox. I suppose there are some problem into proxy or loader object infact store is always empty.

Server call is ok (tested with dedugger)
Please help me...

this is my code


public class TrialDTOCombo extends ComboBox<BeanModel> {
private static final String COL_ID = TrialDTO.ID;
private static final String COL_TYPE_COMPETITION = TrialDTO.DESCRIPTION;
private static final String DEFAULT_SORT = TrialDTO.DESCRIPTION;
private static final String LOADING_TEXT = "In caricamento";
private static final String EMPTY_TEXT = "Scegli la prova";


private final TrialGWTServiceAsync service = (TrialGWTServiceAsync) GWT.create(TrialGWTService.class);


public TrialDTOCombo() {
super();

// proxy, reader and loader
RpcProxy<List<TrialDTO>> proxy = new RpcProxy<List<TrialDTO>>() {
@Override
public void load(Object loadConfig, AsyncCallback<List<TrialDTO>> callback) {
service.loadAll(callback);
}

};

BeanModelReader reader = new BeanModelReader();
ListLoader<ListLoadResult<TrialDTO>> loader = new BaseListLoader<ListLoadResult<TrialDTO>>(proxy, reader);
loader.setSortField(DEFAULT_SORT);
loader.setSortDir(SortDir.ASC);
loader.setRemoteSort(true);
loader.load();


ListStore<BeanModel> localStore = new ListStore<BeanModel>(loader);
loader.load();

this.setStore(localStore);

this.setDisplayField(COL_TYPE_COMPETITION);
this.setValueField(COL_ID);
this.setName(COL_TYPE_COMPETITION);
this.setFieldLabel(COL_TYPE_COMPETITION);
this.setForceSelection(true);
this.setLoadingText(LOADING_TEXT);
this.setEmptyText(EMPTY_TEXT);
this.setTriggerAction(TriggerAction.ALL);
this.setUseQueryCache(true);
}
}


form code


TrialDTOCombo wCustomer = new TrialDTOCombo();
...
form.add(wCustomer);
...


dto code


public final class TrialDTO extends BeanModel implements BeanModelTag, Serializable{

public final static String ID = "id";
public final static String DESCRIPTION = "description";
public final static String NOTE = "note";


public TrialDTO(){
setId(0);
setDescription("");
setNote("");

}

public TrialDTO(TrialDTO record) {
setId(record.getId());
setDescription(record.getDescription());
setNote(record.getNote());
}



public TrialDTO(Integer id, String description, String note){
setId(id);
setDescription(description);
setNote(note);
}

public Integer getId() {
return (Integer)get(ID);
}

public void setId(Integer id) {
set(ID, id);
}

public String getDescription() {
return (String)get(DESCRIPTION);
}

public void setDescription(String description) {
set(DESCRIPTION, description);
}

public String getNote() {
return (String)get(NOTE);

}

public void setNote(String note) {
set(NOTE, note);
}

@Override
public String toString() {
return "TrialDTO{ ID = " + getId() +
" Description= " + getDescription() +
" Note = " + getNote() +
"}";
}


}


After combo click this is response from server


INFO: com.estefancivera.hresource.beans.Trial[ id=3 ]
INFO: TrialDTO{ ID = 3 Description= Taglio Termico Note = Questa prova permette di gestire...}
INFO: com.estefancivera.hresource.beans.Trial[ id=4 ]
INFO: TrialDTO{ ID = 4 Description= Saldatura Note = La prova di saldatura....}
INFO: com.estefancivera.hresource.beans.Trial[ id=5 ]
INFO: TrialDTO{ ID = 5 Description= Estrusione Note = estrusione}

but widget will never populate!! :(

estefan.civera
14 Jun 2011, 4:49 AM
I solved this situation removing these code lines

BeanModelReader reader = new BeanModelReader();
ListLoader<ListLoadResult<TrialDTO>> loader = new BaseListLoader<ListLoadResult<TrialDTO>>(proxy, reader);


replaced with
ListLoader<ListLoadResult<TrialDTO>> loader = new BaseListLoader<ListLoadResult<TrialDTO>>(proxy);