Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] DataSource Using URL w/ Query Parameters

Expand Messages
  • Satyam
    It is better to place the query arguments in the configuration options of the DataTable constructor, in the fourth argument var myDataTable = new
    Message 1 of 10 , Dec 3, 2007
    View Source
    • 0 Attachment
      It is better to place the query arguments in the configuration options of
      the DataTable constructor, in the fourth argument

      var myDataTable = new
      YAHOO.widget.DataTable(container,myColumnDef,myDataSource,{initialRequest:'id=0&group=ProverME'});

      In that way, if you reuse the DataSource for server-side paging, sorting or
      just refreshing the data from the database, the URL stored in the DataSource
      does not include the arguments for an initial request, which might not be
      suitable for further requests. Besides, if you use POST requests, having
      the URL split like this will put the arguments in the post data.
      Nevertheless, I'm surprised that you won't get the arguments on the server
      side. Where you looking for them along the post data? They wouldn't be
      there even if you set the connection to post because you explicitly placed
      them in the query string.

      Satyam


      ----- Original Message -----
      From: "Randall R Schulz" <rschulz@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Monday, December 03, 2007 12:14 AM
      Subject: [ydn-javascript] DataSource Using URL w/ Query Parameters


      > Hi,
      >
      > After this example in Satyam's tutorial blog
      > (<http://yuiblog.com/blog/2007/09/12/satyam-datatable/>):
      >
      > var myDataSource = new YAHOO.util.DataSource("http://url/datafeed.php?");
      >
      >
      > I used this call in my code:
      >
      > var myDataSource = new
      > YAHOO.util.DataSource("/tgi/settings/groupSettings?id=0&group=ProverME")
      >
      >
      > But the URL submitted does not include the query parameters.
      >
      > What's am I doing wrong?
      >
      >
      > Randall Schulz
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.503 / Virus Database: 269.16.13/1165 - Release Date:
      > 02/12/2007 20:34
      >
      >
    • Randall R Schulz
      ... Better suggests there s an alternative. ... That won t happen. This is not a database-backed application: there is no paging and never will be any. ...
      Message 2 of 10 , Dec 3, 2007
      View Source
      • 0 Attachment
        On Monday 03 December 2007 00:53, Satyam wrote:
        > It is better to place the query arguments in the configuration
        > options of the DataTable constructor, in the fourth argument

        "Better" suggests there's an alternative.


        > var myDataTable = new
        > YAHOO.widget.DataTable(container,myColumnDef,myDataSource,{initialReq
        >uest:'id=0&group=ProverME'});
        >
        > In that way, if you reuse the DataSource for server-side paging,
        > sorting or just refreshing the data from the database,

        That won't happen. This is not a database-backed application: there is
        no paging and never will be any.


        > the URL stored
        > in the DataSource does not include the arguments for an initial
        > request, which might not be suitable for further requests.

        But in my case it is fixed and there will only ever be one request.


        > Besides,
        > if you use POST requests, having the URL split like this will put the
        > arguments in the post data. Nevertheless, I'm surprised that you
        > won't get the arguments on the server side. Where you looking for
        > them along the post data? They wouldn't be there even if you set the
        > connection to post because you explicitly placed them in the query
        > string.

        The server is a Grails applicatino, and it handles POST without
        problems.


        > Satyam


        Randall Schulz
      • Randall R Schulz
        ... I tried this, but the resulting URL is the same (no query parameters; not even the question mark). I did add the question mark to the end of the base URL
        Message 3 of 10 , Dec 3, 2007
        View Source
        • 0 Attachment
          On Monday 03 December 2007 00:53, Satyam wrote:
          > It is better to place the query arguments in the configuration
          > options of the DataTable constructor, in the fourth argument
          >
          > var myDataTable = new
          > YAHOO.widget.DataTable(container,myColumnDef,myDataSource,{initialReq
          >uest:'id=0&group=ProverME'});

          I tried this, but the resulting URL is the same (no query parameters;
          not even the question mark).

          I did add the question mark to the end of the base URL used when
          constructing the DataSource. Oddly enough, without the question mark on
          the base URL given to the DataSource, the server received a URL that
          _was_ concatenated with the initialRequest: string.


          Hmmm... Maybe the POST is the problem (though I know it should not be).
          It could be a bug in Grails. I'll have to take it up with them.


          > ...
          >
          > Satyam


          Randall Schulz
        • Randall R Schulz
          ... While I try to sort out the problems Grails seems to be having with POST requests, at least some of them, is there a way to get DataTable / DataSource to
          Message 4 of 10 , Dec 3, 2007
          View Source
          • 0 Attachment
            On Monday 03 December 2007 00:53, Satyam wrote:
            > ... Besides,
            > if you use POST requests, having the URL split like this will put the
            > arguments in the post data. Nevertheless, I'm surprised that you
            > won't get the arguments on the server side. Where you looking for
            > them along the post data? They wouldn't be there even if you set the
            > connection to post because you explicitly placed them in the query
            > string.

            While I try to sort out the problems Grails seems to be having with POST
            requests, at least some of them, is there a way to get DataTable /
            DataSource to use a GET to retrieve its data? I wasn't able to find
            anything that suggests I can control this (but using such a common word
            as "GET" in a web search tends to confound things).

            Alos, GET seems much more appropriate for a pure information retrieval
            operation, which surely characterizes any request whose purpose is to
            populate a client-side data structure or display. Why do DataSource /
            DataTable use POST?


            > Satyam


            Randall Schulz
          • Randall R Schulz
            ... Welcome (me) to the world of open source development (on the bleeding edge). It _was_ a Grails problem and the fix went into the snapshot builds earlier
            Message 5 of 10 , Dec 3, 2007
            View Source
            • 0 Attachment
              On Monday 03 December 2007 09:27, Randall R Schulz wrote:
              > ...
              >
              > While I try to sort out the problems Grails seems to be having with
              > POST requests, at least some of them, is there a way to get DataTable
              > / DataSource to use a GET to retrieve its data? I wasn't able to find
              > anything that suggests I can control this (but using such a common
              > word as "GET" in a web search tends to confound things).

              Welcome (me) to the world of open source development (on the bleeding
              edge). It _was_ a Grails problem and the fix went into the snapshot
              builds earlier this morning.


              > Also, GET seems much more appropriate for a pure information
              > retrieval operation, which surely characterizes any request whose
              > purpose is to populate a client-side data structure or display. Why
              > do DataSource / DataTable use POST?

              I'd still like to know if GET is an option. I found one Nabble entry
              where a person was asking if he could use POST instead of GET, which
              suggests it is, or at least was, possible. But I still haven't found
              any details on how to control which HTTP request method is used by
              DataSource and / or DataTable.


              Randall Schulz
            • Satyam
              ... From: Randall R Schulz To: Sent: Monday, December 03, 2007 4:38 PM Subject: Re: [ydn-javascript]
              Message 6 of 10 , Dec 3, 2007
              View Source
              • 0 Attachment
                ----- Original Message -----
                From: "Randall R Schulz" <rschulz@...>
                To: <ydn-javascript@yahoogroups.com>
                Sent: Monday, December 03, 2007 4:38 PM
                Subject: Re: [ydn-javascript] DataSource Using URL w/ Query Parameters
                >
                > The server is a Grails applicatino, and it handles POST without
                > problems.

                I'm sure your application can handle post, the problem is that if you append
                it to the URL the data won't be there but in the GET part. I don't know
                Grails, but in PHP you have a $_POST array and a $_GET array. If you append
                arguments to the URL you get them in the $_GET array.

                >
                >
                >> Satyam
                >
                >
                > Randall Schulz
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
                >
                > --
                > No virus found in this incoming message.
                > Checked by AVG Free Edition.
                > Version: 7.5.503 / Virus Database: 269.16.13/1165 - Release Date:
                > 02/12/2007 20:34
                >
                >
              • Randall R Schulz
                ... Grails unifies the decoding of request parameters without regard to whether it s GET, PUT, POST or DELETE and presents all parameters to the handler code
                Message 7 of 10 , Dec 3, 2007
                View Source
                • 0 Attachment
                  On Monday 03 December 2007 10:11, Satyam wrote:
                  > ----- Original Message -----
                  > From: "Randall R Schulz" <rschulz@...>
                  > To: <ydn-javascript@yahoogroups.com>
                  > Sent: Monday, December 03, 2007 4:38 PM
                  > Subject: Re: [ydn-javascript] DataSource Using URL w/ Query
                  > Parameters
                  >
                  > > The server is a Grails applicatino, and it handles POST without
                  > > problems.
                  >
                  > I'm sure your application can handle post, the problem is that if you
                  > append it to the URL the data won't be there but in the GET part. I
                  > don't know Grails, but in PHP you have a $_POST array and a $_GET
                  > array. If you append arguments to the URL you get them in the $_GET
                  > array.

                  Grails unifies the decoding of request parameters without regard to
                  whether it's GET, PUT, POST or DELETE and presents all parameters to
                  the handler code as a simple map (a.k.a. hash). This includes
                  multipart/form data and file uploads, too.

                  Anyway, the real problem was a Grails bug (already found and fixed, as
                  of this morning).

                  But at the risk of repeating myself, I would like to know how to select
                  which HTTP request method is used, if that's possible. POST might not
                  always be a good choice.



                  Randall Schulz
                • Satyam
                  ... From: Randall R Schulz To: Sent: Monday, December 03, 2007 7:03 PM Subject: Re: [ydn-javascript]
                  Message 8 of 10 , Dec 3, 2007
                  View Source
                  • 0 Attachment
                    ----- Original Message -----
                    From: "Randall R Schulz" <rschulz@...>
                    To: <ydn-javascript@yahoogroups.com>
                    Sent: Monday, December 03, 2007 7:03 PM
                    Subject: Re: [ydn-javascript] DataSource Using URL w/ Query Parameters


                    > On Monday 03 December 2007 09:27, Randall R Schulz wrote:
                    >> ...
                    >>
                    >> While I try to sort out the problems Grails seems to be having with
                    >> POST requests, at least some of them, is there a way to get DataTable
                    >> / DataSource to use a GET to retrieve its data? I wasn't able to find
                    >> anything that suggests I can control this (but using such a common
                    >> word as "GET" in a web search tends to confound things).

                    Yes, the connMethodPost property of the DataSource lets you decide on that.

                    http://developer.yahoo.com/yui/docs/YAHOO.util.DataSource.html#connMethodPost

                    The default is false, which means queries will be sent as GET requests.
                    Setting it to true will tell the DataSource to do a POST: In that case, the
                    URL base you set when you instantiate the DataSource will be used as the
                    server address and the arguments set in the initialRequest configuration
                    parameter of the DataTable will be in the POST data.

                    Usually, when you retrieve information, when you only sent a few arguments
                    to identify what is it you want, you would usually use a GET request because
                    that is basically what you are doing, you want to get something and you are
                    telling the server what is it. On the other hand, when you meant to change
                    something in the server, then you use a POST request. In a GET request you
                    send a few bytes and you get a usualyl large response. In a post data the
                    opposite is true, you send possibly a lot of data and you receive an Ok,
                    well, in AJAX you usually do, in normal web pages, you would receive the OK
                    framed in a full HTML page. Thus, GET has limits as to the amount of data
                    it can send to the server, it depends on each browser and has even changed
                    in between versions so never attept to send the contents of an unlimited
                    textarea in a GET since it might silently truncate it. POST does not have
                    practical limits in neither direction. On the other hand, a GET request you
                    can add to the browser bookmarks or favorites and it will store its
                    arguments, in a POST requests, the arguments will never go into the
                    bookmark. For AJAX transactions, the user doesn't see them so he cannot
                    bookmark them. Thus, I prefer POST, specially since YUI makes it simple to
                    use either. I don't use the History Manager so I don't know if it matters
                    there. In the examples in the YUI blog articles, I used GET most of the
                    time, except for the inline-cell editing examples because they deserve a
                    POST.

                    >
                    > Welcome (me) to the world of open source development (on the bleeding
                    > edge). It _was_ a Grails problem and the fix went into the snapshot
                    > builds earlier this morning.
                    >
                    >
                    >> Also, GET seems much more appropriate for a pure information
                    >> retrieval operation, which surely characterizes any request whose
                    >> purpose is to populate a client-side data structure or display. Why
                    >> do DataSource / DataTable use POST?

                    They don't the default is GET.

                    >
                    > I'd still like to know if GET is an option. I found one Nabble entry
                    > where a person was asking if he could use POST instead of GET, which
                    > suggests it is, or at least was, possible. But I still haven't found
                    > any details on how to control which HTTP request method is used by
                    > DataSource and / or DataTable.
                    >

                    see above.

                    Satyam


                    >
                    > Randall Schulz
                    >
                    >
                    >
                    > Yahoo! Groups Links
                    >
                    >
                    >
                    >
                    >
                    > --
                    > No virus found in this incoming message.
                    > Checked by AVG Free Edition.
                    > Version: 7.5.503 / Virus Database: 269.16.13/1165 - Release Date:
                    > 02/12/2007 20:34
                    >
                    >
                  • Randall R Schulz
                    ... Thanks. Of course, it was staring me in the face all along. I don t know why I couldn t find it. ... Randall Schulz
                    Message 9 of 10 , Dec 3, 2007
                    View Source
                    • 0 Attachment
                      On Monday 03 December 2007 10:34, Satyam wrote:
                      > ----- Original Message -----
                      > From: "Randall R Schulz" <rschulz@...>
                      > To: <ydn-javascript@yahoogroups.com>
                      > Sent: Monday, December 03, 2007 7:03 PM
                      > Subject: Re: [ydn-javascript] DataSource Using URL w/ Query
                      > Parameters
                      >
                      > > On Monday 03 December 2007 09:27, Randall R Schulz wrote:
                      > >> ...
                      > >>
                      > >> While I try to sort out the problems Grails seems to be having
                      > >> with POST requests, at least some of them, is there a way to get
                      > >> DataTable / DataSource to use a GET to retrieve its data? I wasn't
                      > >> able to find anything that suggests I can control this (but using
                      > >> such a common word as "GET" in a web search tends to confound
                      > >> things).
                      >
                      > Yes, the connMethodPost property of the DataSource lets you decide on
                      > that.
                      >
                      > http://developer.yahoo.com/yui/docs/YAHOO.util.DataSource.html#connMe
                      >thodPost

                      Thanks. Of course, it was staring me in the face all along. I don't know
                      why I couldn't find it.


                      > ...
                      >
                      > Satyam


                      Randall Schulz
                    Your message has been successfully submitted and would be delivered to recipients shortly.