smartGWT: retrieve data from server to populate a listGrid

Posted by Gabriele on Stack Overflow See other posts from Stack Overflow or by Gabriele
Published on 2010-06-05T14:42:20Z Indexed on 2010/06/05 14:42 UTC
Read the original article Hit count: 312

Filed under:
|

I'm searching a way to populate a ListGrid with an XML response from a server.

This is an example of my server response:

<?xml version="1.0" encoding="UTF-8"?>
  <tbody id="tbody">
    <tr>
      <word>The</word>
      <frequence>12</frequence>
    </tr>
    <tr>
       <word>best</word>
       <frequence>3</frequence>
    </tr>
    ...

And this is how I can populate the ListGrid using a file (item.xml) where I have saved the xml result:

public class Frequenze extends DataSource {
    private static Frequenze instance = null;

      public static Frequenze getInstance() 
      {
        if (instance == null) {
            instance = new Frequenze("frequence");
        }
        return instance;
      }

      public Frequenze(String id) 
      {
            setID(id);
            setRecordXPath("//tr");
            DataSourceTextField wordField = new DataSourceTextField("word", "Word");
            wordField.setRequired(true);

            DataSourceIntegerField frequenceField = new DataSourceIntegerField("frequence", "Frequence");
            frequenceField.setRequired(true);

            setFields(wordField, frequenceField);

            setDataURL("ds/item.xml");
            setClientOnly(true);
      }
}

Now I want not to use the file, but I'm searching a way to retrieve the data directly from the server. Anyone know how I get this?

© Stack Overflow or respective owner

Related posts about java

Related posts about smartgwt