1. #1
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    17
    Vote Rating
    0
    bhupesh117 is on a distinguished road

      0  

    Default Cannot populate ComboBox using RpcProxy call

    Cannot populate ComboBox using RpcProxy call


    Hello All,

    This is my very first project with GXT and I am stuck at populating ComboBox.I am trying to populate data into my ComboBox, by making a simple RpcProxy call to back-end server. In my back-end server, I have parsed XML documents and created a Java bean which I am trying to show on UI.

    I am using following:

    -GXT 2.2.5
    -ComboBox
    -ListStore
    -RpcProxy

    Below is the implementation of my ComboBox:

    import com.extjs.gxt.ui.client.Registry;
    import com.extjs.gxt.ui.client.data.BaseListLoader;
    import com.extjs.gxt.ui.client.data.BeanModelReader;
    import com.extjs.gxt.ui.client.data.ListLoadResult;
    import com.extjs.gxt.ui.client.data.ListLoader;
    import com.extjs.gxt.ui.client.data.RpcProxy;
    import com.extjs.gxt.ui.client.store.ListStore;
    import com.extjs.gxt.ui.client.widget.LayoutContainer;
    import com.extjs.gxt.ui.client.widget.form.ComboBox;
    import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
    import com.google.gwt.user.client.Element;
    import com.google.gwt.user.client.rpc.AsyncCallback;


    public class myComboBox extends LayoutContainer {
    ComboBox<MyBean> myComboBox = new ComboBox<MyBean>();

    @Override
    protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    final MyServiceAsync service = (MyServiceAsync)
    Registry.get(TestAnalysisConstatns.MY_SERVICE);

    try{
    RpcProxy<MyBean> proxy = new RpcProxy<MyBean>() {
    @Override
    protected void load(Object loadConfig,
    AsyncCallback<MyBean> callback) {
    service.createNewReportCard(callback);
    }
    };
    BeanModelReader reader = new BeanModelReader();
    ListLoader<ListLoadResult<MyBean>> loader =
    new BaseListLoader<ListLoadResult<MyBean>>( proxy);
    ListStore<MyBean> comboStore = new ListStore<MyBean>(loader);


    myComboBox.setStore(comboStore);
    myComboBox.setDisplayField("name");
    myComboBox.setValueField("name");

    myComboBox.setEditable(false);
    myComboBox.setWidth(150);
    myComboBox.setTriggerAction(TriggerAction.ALL);
    add(myComboBox);

    loader.load();
    }catch(Exception e){
    e.printStackTrace();
    }
    }

    }

    One weird issue with the above code is that while creating loader, if I use both proxy and reader object I am getting "java.lang.AssertionError: Error converting data" exception. But If I use only proxy, I can see that my "MyBean" is getting populated from back-end but its not showing data on UI.

    Below is the code for MyBean object:

    import java.io.Serializable;


    import com.extjs.gxt.ui.client.data.BaseModelData;








    public class MyBean extends BaseModelData implements Serializable {
    private String id;
    private String name;
    private String reportType;
    private String catalogType;
    private String catalogVersion;



    public String getId() {
    return id;
    }
    public void setId(String id) {
    this.id = id;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getReportType() {
    return reportType;
    }
    public void setReportType(String reportType) {
    this.reportType = reportType;
    }
    public String getCatalogType() {
    return catalogType;
    }
    public void setCatalogType(String catalogType) {
    this.catalogType = catalogType;
    }
    public String getCatalogVersion() {
    return catalogVersion;
    }
    public void setCatalogVersion(String catalogVersion) {
    this.catalogVersion = catalogVersion;
    }
    }

    I would really appreciate any help with this.!!

  2. #2
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    17
    Vote Rating
    0
    bhupesh117 is on a distinguished road

      0  

    Default


    I found solution for the problem. I was trying to get a single object back from RpcProxy call to back-end and setting that into ListStore. But it seems to me that you cannot do that in GXT. You have to create entire list and pass that list to UI in order to populate your ListStore.