Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Confusion with web server binding

    Hi,

    It is probably only a tiny setting but I am banging my head around it for a while.
    I am trying to set up a client side datasource to query a geolocation server.
    Documentation on how to query it can be found here: http://open.mapquestapi.com/nominatim/

    Since I thought it would be the most efficient to use JSON, I extended the XJSONDataSource and set
    Code:
     
    setDataFormat(DSDataFormat.JSON); //just to be sure
    DSRequest dsr = new DSRequest();
    dsr.setCallbackParam("json_callback"); //the server expects the callback method parameter to be like this
    setRequestProperties(dsr);
    setRecordXPath("//"); //setting it seems to make no difference
    setDataURL("http://open.mapquestapi.com/nominatim/v1/search");
    
    //Field definitions
    DataSourceField osm_id = new DataSourceTextField("osm_id");
    osm_id.setPrimaryKey(true);
    osm_id.setHidden(true);
    // AutoIncrement on server.
    osm_id.setRequired(true);
    addField(osm_id);
    
    DataSourceField boundingbox = new DataSourceTextField("boundingbox");
    boundingbox.setMultiple(true);
    addField(boundingbox);
    
    //a nested field
    DataSourceTextField clazz = new DataSourceTextField("class");
    clazz.setValueXPath("address");
    addField(clazz);
    
    DataSourceField licence = new DataSourceTextField("licence");
    addField(licence);
    ...
    The query string transmitted to the server (after setting the corresponding criteria) is then e.g.
    Code:
    http://open.mapquestapi.com/nominatim/v1/search?q=Manassas&format=json&json_callback=isc.Comm._scriptIncludeReply_1
    Using Firebug, the response seems to turn out to be like an array that contains Maps, e.g.:
    Code:
    isc.Comm._scriptIncludeReply_1(
    [  {
          "place_id":"504794",
          "licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",
          "osm_type":"node",
          "osm_id":"158544740",
          "boundingbox":[
             "38.7409460449",
             "38.7609498596",
             "-77.4852731323",
             "-77.4652655029"
          ],
          "lat":"38.7509488",
          "lon":"-77.4752667",
          "display_name":"Manassas, Manassas (city), Virginia, United States of America",
          "class":"place",
          "type":"town",
          "icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/poi_place_town.p.20.png"
       },
       {
          "place_id":"79456270",
          "licence":"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",
          "osm_type":"relation",
          "osm_id":"206870",
          "boundingbox":[
             "38.7079010009766",
             "38.7814140319824",
             "-77.5266799926758",
             "-77.447509765625"
          ],
          "lat":"38.7480051041384",
          "lon":"-77.4838009846557",
          "display_name":"Manassas, Prince William County, Virginia, United States of America",
          "class":"boundary",
          "type":"administrative",
          "icon":"http://open.mapquestapi.com/nominatim/v1/images/mapicons/poi_boundary_administrative.p.20.png"
       },
    ...])
    The GWT DSCallback is called, response.getStatus() is 0, but response.getData().length is 0 as well. The develompment console indicates a successful call, so it must be a small binding issue. I searched the Quick Start Guide and the corresponding docs and studied the showcase examples but haven't found an example that works with json and callbacks.

    What am I missing here?

    Thanks
    fatzopilot

    #2
    To be sure to not missing the obvious, could somebody come up with a simple example (at best, using a public server) that uses JSON as a message format and a json-callback?

    Thanks
    fatzopilot

    Comment


      #3
      Setting
      setRecordXPath("/");
      instead of
      setRecordXPath("//");
      solves the problem.

      Comment

      Working...
      X