Grails
  1. Grails
  2. GRAILS-3406 Top level task: Controller Improvements
  3. GRAILS-1243

Improve support for Controllers to be placed in sub-folders/packages.

    Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.3, 0.4
    • Fix Version/s: 2.2
    • Component/s: Controllers
    • Labels:
      None

      Description

      Add support for placing controllers in sub-folders/packages within the controllers folder so you can keep related controllers together, create more structured urls and make path based url security easier?

      For example:

      \grails-app\controllers\SiteController.groovy -> http://localhost:8080/sample/site
      \grails-app\controllers\admin\UserController.groovy -> http://localhost:8080/sample/admin/user
      \grails-app\controllers\admin\RoleController.groovy -> http://localhost:8080/sample/admin/role

      And views would obviously have to follow the package structure of their controller:

      \grails-app\views\admin\user\show.gsp

        Issue Links

          Activity

          Hide
          Jean du Plessis added a comment -

          @Jeff, that would definitely help in terms of keeping url structures clean and organised, but another factor that is missing is having a structured code base - which is something I think the original request for this ticket desired.

          Now take for instance the example of Facebook tabs. What would be ideal is if you could have a project structure like this:

          grails-app
          - controllers
           - campaignx
            - TabController.groovy
           - campaigny
            - TabController.groovy
          - views
           - campaignx
            - tab
             - like.gsp
             - page.gsp
           - campaigny
            - tab
             - like.gsp
             - page.gsp
          

          The above would map to a url structure:
          http://domain/campaignx/tab/like
          http://domain/campaignx/tab/page
          http://domain/campaigny/tab/like
          http://domain/campaigny/tab/page

          What it comes down to is having the ability to have the package name determine directory and url structure. Currently while you can package controllers in different packages, it doesn't influence the view directory and url structures for that controller.

          Having a consistent convention for packaging controllers, view directory and url structure would simply things.

          Show
          Jean du Plessis added a comment - @Jeff, that would definitely help in terms of keeping url structures clean and organised, but another factor that is missing is having a structured code base - which is something I think the original request for this ticket desired. Now take for instance the example of Facebook tabs. What would be ideal is if you could have a project structure like this: grails-app - controllers - campaignx - TabController.groovy - campaigny - TabController.groovy - views - campaignx - tab - like.gsp - page.gsp - campaigny - tab - like.gsp - page.gsp The above would map to a url structure: http://domain/campaignx/tab/like http://domain/campaignx/tab/page http://domain/campaigny/tab/like http://domain/campaigny/tab/page What it comes down to is having the ability to have the package name determine directory and url structure. Currently while you can package controllers in different packages, it doesn't influence the view directory and url structures for that controller. Having a consistent convention for packaging controllers, view directory and url structure would simply things.
          Hide
          Klaus Lehner added a comment -

          yes, this is exactly what I've requested in GRAILS-10090, I would appreciate that as well

          Show
          Klaus Lehner added a comment - yes, this is exactly what I've requested in GRAILS-10090 , I would appreciate that as well
          Hide
          Jeff Scott Brown added a comment -

          I think there are reasonable requests there. This JIRA ended up conflating several things, one of which has been resolved. I prefer to leave this closed as it is a source of confusion as it is. The GRAILS-10090 request is specific and reasonable. Separate from that might be a request to support something related to URL mappings (GRAILS-10090 is only about the view directories).

          Thanks again for your input.

          Show
          Jeff Scott Brown added a comment - I think there are reasonable requests there. This JIRA ended up conflating several things, one of which has been resolved. I prefer to leave this closed as it is a source of confusion as it is. The GRAILS-10090 request is specific and reasonable. Separate from that might be a request to support something related to URL mappings ( GRAILS-10090 is only about the view directories). Thanks again for your input.
          Hide
          Jean du Plessis added a comment -

          Thanks Jeff - understand your reason for wanting to keep this request closed.
          In addition to GRAILS-10090 opened by Klaus I have opened GRAILS-10092 to deal with the controller namespace URL mapping.

          Show
          Jean du Plessis added a comment - Thanks Jeff - understand your reason for wanting to keep this request closed. In addition to GRAILS-10090 opened by Klaus I have opened GRAILS-10092 to deal with the controller namespace URL mapping.
          Hide
          boillod manuel added a comment -

          I think that a new convention could help, wihthout using url namespaces.

          If we add a 'controller.package.prefix' option in Config.groovy, we can properly handle a good convention for view directories. See the example below for details:

          Config.groovy:

          • controller.package.prefix='com.zenika'

          Controllers:

          • com.zenika.UserController
          • com.zenika.admin.UserController
          • com.zenika.public.user.AccountController

          View directories (based on this convention)

          • user/
          • admin/user/
          • public/user/account

          What do you think about it ?

          Manuel

          Show
          boillod manuel added a comment - I think that a new convention could help, wihthout using url namespaces. If we add a 'controller.package.prefix' option in Config.groovy, we can properly handle a good convention for view directories. See the example below for details: Config.groovy: controller.package.prefix='com.zenika' Controllers: com.zenika.UserController com.zenika.admin.UserController com.zenika.public.user.AccountController View directories (based on this convention) user/ admin/user/ public/user/account What do you think about it ? Manuel

            People

            • Assignee:
              Jeff Scott Brown
              Reporter:
              Victor Volle
            • Votes:
              70 Vote for this issue
              Watchers:
              67 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Last Reviewed:

                Development