PDA

View Full Version : ComboBox<BeanModel> is empty



treblereel
30 Mar 2011, 2:16 PM
Hi all,

My Combo populating only after i have pressing array-button on combo. Howdo i can fix it ?
Thanks



DepartmentServiceAsync departmentService = GWT.create(DepartmentService.class);
ListLoader<?> loader;

RpcProxy<List<DepartmentDTO>> DepartmentProxy = new RpcProxy<List<DepartmentDTO>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<List<DepartmentDTO>> callback) {
departmentService.getDepartments("any",callback);
}
};

loader = new BaseListLoader<ListLoadResult<ModelData>>(DepartmentProxy,new BeanModelReader());
departmentStore = new ListStore<BeanModel>(loader);
loader.load();



departmentComboBox = new ComboBox<BeanModel>();
departmentComboBox.setDisplayField("name");
departmentComboBox.setWidth(150);
departmentComboBox.setName("department");
departmentComboBox.setFieldLabel("Department");
departmentComboBox.setAllowBlank(false);
departmentComboBox.setEditable(false);
departmentComboBox.setStore(departmentStore);
departmentComboBox.setTriggerAction(TriggerAction.ALL);

ituren
30 Mar 2011, 10:17 PM
Can you please attach the code of class DepartmentDTO ?

treblereel
30 Mar 2011, 11:35 PM
sure





public class DepartmentDTO implements Serializable, BeanModelTag{

/**
*
*/
private static final long serialVersionUID = 1L;



private Integer id;
private UserDTO owner;
private Boolean status;
private String name;
private String note;
private Date started;
private Date finished;
private Date updated;


public DepartmentDTO(){

}




public DepartmentDTO(Department department){
this.setId(department.getId());
this.setStatus(department.getStatus());
this.setName(department.getName());
this.setNote(department.getNote());
this.setStarted(department.getStarted());
this.setFinished(department.getFinished());
this.setUpdated(department.getUpdated());

}





public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}

public UserDTO getOwner() {
return owner;
}
public void setOwner(UserDTO owner) {
this.owner = owner;
}

public Boolean getStatus() {
return status;
}
public void setStatus(Boolean status) {
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public Date getStarted() {
return started;
}
public void setStarted(Date started) {
this.started = started;
}
public Date getFinished() {
return finished;
}
public void setFinished(Date finished) {
this.finished = finished;
}
public Date getUpdated() {
return updated;
}
public void setUpdated(Date updated) {
this.updated = updated;
}

public Department getDepartment(){
return new Department(this);
}







}

ituren
31 Mar 2011, 1:18 AM
I used your code.And it works fine for me.


public class Gxt_test implements EntryPoint {

private final GreetingServiceAsync greetingService = GWT
.create(GreetingService.class);
private ListStore<BeanModel> departmentStore;

public void onModuleLoad() {
ListLoader<?> loader;

RpcProxy<List<DepartmentDTO>> DepartmentProxy = new RpcProxy<List<DepartmentDTO>>() {
@Override
protected void load(Object loadConfig,
AsyncCallback<List<DepartmentDTO>> callback) {
greetingService.greetServer(callback);
}
};

loader = new BaseListLoader<ListLoadResult<ModelData>>(DepartmentProxy,
new BeanModelReader());
departmentStore = new ListStore<BeanModel>(loader);
loader.load();

ComboBox<BeanModel> departmentComboBox = new ComboBox<BeanModel>();
departmentComboBox.setDisplayField("name");
departmentComboBox.setWidth(150);
departmentComboBox.setName("department");
departmentComboBox.setFieldLabel("Department");
departmentComboBox.setAllowBlank(false);
departmentComboBox.setEditable(false);
departmentComboBox.setStore(departmentStore);
departmentComboBox.setTriggerAction(TriggerAction.ALL);

RootPanel.get().add(departmentComboBox);
}
}