Grails
  1. Grails
  2. GRAILS-7196

g:paginate doesn't work with RESTful URLs

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.6
    • Fix Version/s: 2.1-RC1
    • Component/s: TagLib
    • Labels:
      None

      Description

      I'm setting up mappings for RESTful URLs including collection resources:

      "/person/$id"(controller:"person"){
          action = [GET:"show", PUT:"update", DELETE:"delete", POST:"save"]
      }
      "/person"(controller:"person") {
          action = [GET:"list", PUT:"update", DELETE:"delete", POST:"save"]
      }
      

      So the URL for viewing a collection is like
      myapp/person
      instead of
      myapp/person/list

      However, the g:paginate tag won't work with this.
      It creates links with "list" in the URL when there is no action name in the URL.

      I changed this line in the paginate tag of RenderTagLib
      def action = (attrs.action ? attrs.action : (params.action ? params.action : "list"))
      to
      def action = (attrs.action ? attrs.action : (params.action ? params.action : ""))

      to get it to work for me.

        Activity

        Show
        Bobby Warner added a comment - Commit – https://github.com/grails/grails-core/commit/c09affbb53b499a50a13f7aaf546eecd712270c6
        Hide
        Bobby Warner added a comment -
        Show
        Bobby Warner added a comment - Pull Request – https://github.com/grails/grails-core/pull/191
        Hide
        Steve Tekell added a comment -

        with Grails 2.x, the small fix still works

        that is, changing "list" to ""

        Show
        Steve Tekell added a comment - with Grails 2.x, the small fix still works that is, changing "list" to ""
        Hide
        Steve Tekell added a comment -

        correction, it is still an issue with v2. It still adds 'list' into the URL. I just fooled myself with a UrlMapping on my first test.

        Show
        Steve Tekell added a comment - correction, it is still an issue with v2. It still adds 'list' into the URL. I just fooled myself with a UrlMapping on my first test.
        Hide
        Steve Tekell added a comment -

        OK, close and if I discover something with further testing, then I'll re-open or create a new ticket.

        Show
        Steve Tekell added a comment - OK, close and if I discover something with further testing, then I'll re-open or create a new ticket.
        Hide
        cdeszaq added a comment -

        If this seems to be fixed in v2.x, then I think we can close this.

        Show
        cdeszaq added a comment - If this seems to be fixed in v2.x, then I think we can close this.
        Hide
        Steve Tekell added a comment -

        Yeah, it worked find with the defaults in 1.3.7.
        Although, with my first test with 2.0 (2.0.3) it appears that the fix is no longer needed. I haven't investigated into what's changed underneath.

        Show
        Steve Tekell added a comment - Yeah, it worked find with the defaults in 1.3.7. Although, with my first test with 2.0 (2.0.3) it appears that the fix is no longer needed. I haven't investigated into what's changed underneath.
        Hide
        cdeszaq added a comment -

        I've updated the description for you.

        Have you tested your change against the "defaults" to see if your change breaks the "normal" (ie. non-rest) functionality? I believe it should work fine because the default default-action is "list", so the pagination should still fall through correctly.

        If it works, submit a patch (and a test-case if you can) and hopefully this will be sure to be included in the upcoming boost in REST support.

        Show
        cdeszaq added a comment - I've updated the description for you. Have you tested your change against the "defaults" to see if your change breaks the "normal" (ie. non-rest) functionality? I believe it should work fine because the default default-action is "list", so the pagination should still fall through correctly. If it works, submit a patch (and a test-case if you can) and hopefully this will be sure to be included in the upcoming boost in REST support.
        Hide
        Steve Tekell added a comment -

        darn I can't edit my own ticket
        I meant to replace "organization" with "person" in all that code

        "/person/$id"(controller:"person"){
            action = [GET:"show", PUT:"update", DELETE:"delete", POST:"save"]
        }
        "/person"(controller:"person") {
            action = [GET:"list", PUT:"update", DELETE:"delete", POST:"save"]
        }
        
        Show
        Steve Tekell added a comment - darn I can't edit my own ticket I meant to replace "organization" with "person" in all that code "/person/$id" (controller: "person" ){ action = [GET: "show" , PUT: "update" , DELETE: "delete" , POST: "save" ] } "/person" (controller: "person" ) { action = [GET: "list" , PUT: "update" , DELETE: "delete" , POST: "save" ] }

          People

          • Assignee:
            Bobby Warner
            Reporter:
            Steve Tekell
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development