Announcement

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

    Example for RestDataSource does not work

    I am new to SmartClient and was just doing some testing for treegrid/datasources. I tried the example from https://isomorphic.atlassian.net/wik...ON+SmartClient using the LGPL download. I get the following error: 'The server failed to return a formatted response at all'.

    Is the wiki example no longer valid? Do I need to make any changes to it? Does the example require the full version?

    #2
    The responses shown in this sample lack the default RestDataSource.jsonPrefix/jsonSuffix, however, the absence of those prefixes should only result in a warning, so you may simply have your URLs wrong - use your browser's built-in tools to check that the response is as expected.

    Comment


      #3
      Originally posted by Isomorphic View Post
      The responses shown in this sample lack the default RestDataSource.jsonPrefix/jsonSuffix, however, the absence of those prefixes should only result in a warning, so you may simply have your URLs wrong - use your browser's built-in tools to check that the response is as expected.
      Actually I have not written any code. I just downloaded the zip file from the example and used it as is under tomcat (maybe you can do the same). The response is exactly as it is in the provided file in the zip (country_fetch_rest.js).
      See below. Can you try the zip file attached to the example (on your wiki page) and if it does not work, please update it?

      {
      response: {
      status: 0,
      startRow: 0,
      endRow: 7,
      totalRows: 7,
      data: [
      {
      continent: "North America",
      countryName: "United States",
      countryCode: "US",
      area: 9631420,
      population: 298444215,
      gdp: 12360000,
      independence: new Date(1776, 07, 04),
      government: "federal republic",
      government_desc: 2,
      capital: "Washington, DC",
      member_g8: true,
      article: "http://en.wikipedia.org/wiki/United_states"
      },
      {
      continent: "Europe",
      countryName: "Germany",
      countryCode: "GM",
      area: 357021,
      population: 82422299,
      gdp: 2504000,
      independence: new Date(1871, 01, 18),
      government: "federal republic",
      government_desc: 2,
      capital: "Berlin",
      member_g8: true,
      article: "http://en.wikipedia.org/wiki/Germany"
      },
      {
      continent: "Europe",
      countryName: "United Kingdom",
      countryCode: "UK",
      area: 244820,
      population: 60609153,
      gdp: 1830000,
      independence: new Date(1801, 01, 01),
      government: "constitutional monarchy",
      government_desc: 1,
      capital: "London",
      member_g8: true,
      article: "http://en.wikipedia.org/wiki/United_kingdom"
      },
      {
      continent: "Europe",
      countryName: "France",
      countryCode: "FR",
      area: 547030,
      population: 60876136,
      gdp: 1816000,
      government: "republic",
      government_desc: 5,
      capital: "Paris",
      member_g8: true,
      article: "http://en.wikipedia.org/wiki/France"
      },
      {
      continent: "South America",
      countryName: "Brazil",
      countryCode: "BR",
      area: 8511965,
      population: 188078227,
      gdp: 1556000,
      independence: new Date(1822, 09, 07),
      government: "federative republic",
      government_desc: 3,
      capital: "Brasilia",
      member_g8: false,
      article: "http://en.wikipedia.org/wiki/Brazil"
      },
      {
      continent: "North America",
      countryName: "Canada",
      countryCode: "CA",
      area: 9984670,
      population: 33098932,
      gdp: 1114000,
      independence: new Date(1867, 07, 01),
      government: "constitutional monarchy with parliamentary democracy and federation",
      government_desc: 1,
      capital: "Ottawa",
      member_g8: true,
      article: "http://en.wikipedia.org/wiki/Canada"
      },
      {
      continent: "North America",
      countryName: "Mexico",
      countryCode: "MX",
      area: 1972550,
      population: 107449525,
      gdp: 1067000,
      independence: new Date(1810, 09, 16),
      government: "federal republic",
      government_desc: 2,
      capital: "Mexico (Distrito Federal)",
      member_g8: false,
      article: "http://en.wikipedia.org/wiki/Mexico"
      }
      ]
      }
      }

      Comment


        #4
        Originally posted by Isomorphic View Post
        The responses shown in this sample lack the default RestDataSource.jsonPrefix/jsonSuffix, however, the absence of those prefixes should only result in a warning, so you may simply have your URLs wrong - use your browser's built-in tools to check that the response is as expected.
        Hi, I updated the response file in your example zip (downloaded from your wiki) - and added prefix/suffix and the example now works (but before it did give an error, not a warning).

        Thanks for your help, but I would suggest updating the example zip on your wiki.

        Comment


          #5
          So again:

          The responses shown in this sample lack the default RestDataSource.jsonPrefix/jsonSuffix
          Either add them to the sample responses, or set both properties on RestDataSource to empty string, as the docs tell you.

          We'll be checking on your reported problem to see whether the sample needs updating, but there's no reason to wait.

          Comment

          Working...
          X