Announcement

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

    Endless loop issue with Json datasource.

    I created my application following the Yahoo JSon example.

    Here is the sample json output from my server
    {"ResultSet":{"totalResultsAvailable":"1","totalResultsReturned":1,"firstResultPosition":1,"Result":[{"Name":"ASM","RoHS_Status":"","LC_State":"Production","Number":"06060621","Revision":"A"}]}}

    Following is my code to create the UI for Json ouput. Whenever I click the search button, UI keeps giving the message "Finding records that match your criteria" . Any help to debug this issue will be helpful.

    Thanks,
    Prathap

    XJSONDataSource yahooDS = new XJSONDataSource();
    yahooDS
    .setDataURL(
    "http://localhost/cgi/BOM.py?username=jim");
    yahooDS.setRecordXPath("/ResultSet/Result");

    ...

    final SearchForm form = new SearchForm();
    form.setTop(50);
    form.setNumCols(3);
    TextItem query = new TextItem();
    query.setName("number");
    query.setTitle("Query");
    query.setDefaultValue("07012774");

    ButtonItem button = new ButtonItem();
    button.setTitle("Search");
    button.setStartRow(false);
    button.addClickHandler(new ClickHandler() {
    public void onClick(ClickEvent event) {
    grid.fetchData(form.getValuesAsCriteria());
    }
    });

    form.setItems(query, button);

    canvas.addChild(form);
    canvas.addChild(grid);
    return canvas;

    #2
    Please let me know if you need any other details.

    Thanks,
    Prathap

    Comment


      #3
      Prathap:

      Couple of things you should take a look at:

      1) The JSON that you're returning does not have certain pieces that are necessary in SmartGWT like the startRow and endRow and the totalRows.

      2) Make sure you open up the Developer's Console and in particular the RPC tab will show you the call that is being made and whether the status returned is valid or not.

      Here's a snippet (not a full JSON object) that demonstrates the type of parameters you'll need to return:

      {response: {"status":"0","startRow":"0","endRow":"665","totalRows":"666","data":[{"id":"2188","attributeID":"19","description":" Blockbuster","parent":"0","editable":"1"}]}}

      Hope this helps.

      Chris

      Comment


        #4
        Thanks for the input Chris.
        It looks like the fetch operation is not getting completed. When I watch the developer console in the rpc tab, I see one line in the history table. But nothing in the request tabkle. Response table shows 'Transaction in Progress' for ever.

        I tested the actual server url directly calling from the browser and it seems to be fine.

        Please let me know if you have any ideas on what is happeing here.


        Thanks,
        Prathap

        Comment


          #5
          Wrapping the json output in the dynamic callback function on server before sending to client solved my problem.

          callback_0({"Name":"ASM","RoHS_Status":"","LC_State":"Product ion","Number":"06060621","Revision":"A"})

          Comment


            #6
            Cool. Glad its all working now.

            Comment

            Working...
            X