Grails JIRA

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile
Grails
  • Grails
  • GRAILS-3406 Top level task: Controller Improvements
  • GRAILS-1980

need ability to specify layout per controller

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-RC2
  • Fix Version/s: 1.1-RC1
  • Component/s: View technologies
  • Labels:
    None
  • Environment:
    n/a

Description

Seems only natural that there would be a way to override the default controller-to-layout-by-name convention. (specifying in each view doesn't really count and violates DRY)
class MyAccountController {
static layout = "main"
...
}

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Git Commits
Hide
Permalink
Graeme Rocher added a comment - 07/Dec/07 5:08 AM

You can, if you have a controller BookController just create a layout called:

grails-app/views/layouts/book.gsp

You can also do per action layouts:

grails-app/views/layouts/book/list.gsp

Show
Graeme Rocher added a comment - 07/Dec/07 5:08 AM You can, if you have a controller BookController just create a layout called: grails-app/views/layouts/book.gsp You can also do per action layouts: grails-app/views/layouts/book/list.gsp
Hide
Permalink
kris helenek added a comment - 07/Dec/07 8:07 AM

I'm not sure how carefully you read my post

I'm aware of the naming convention and the ability to override it per view, but for some reason you cannot do it per controller. For example, if you have a BookController, and a MovieController, and both use the same layout, why not allow them both to specify the same controller:

BookController{
static layout = "product"
}

MovieController{
static layout = "product"
}

If you have many views per controller, specifying in each view is tedious and violates DRY, and the controller is the most likely level of granularity for layout changes.

Show
kris helenek added a comment - 07/Dec/07 8:07 AM I'm not sure how carefully you read my post I'm aware of the naming convention and the ability to override it per view , but for some reason you cannot do it per controller . For example, if you have a BookController, and a MovieController, and both use the same layout, why not allow them both to specify the same controller: BookController{ static layout = "product" } MovieController{ static layout = "product" } If you have many views per controller, specifying in each view is tedious and violates DRY, and the controller is the most likely level of granularity for layout changes.
Hide
Permalink
Graeme Rocher added a comment - 07/Dec/07 8:08 AM

Ok we'll look to support this post 1.0

Show
Graeme Rocher added a comment - 07/Dec/07 8:08 AM Ok we'll look to support this post 1.0
Hide
Permalink
Andreas Arledal added a comment - 22/Jan/09 5:49 PM

Totally agree on this one, and it should also be possible to change layout per action. For example in Rails you can do it like this:

class MyController < ApplicationController
  layout "main", only [:index]
  layout "admin", except [:index]
  ...
end
Show
Andreas Arledal added a comment - 22/Jan/09 5:49 PM Totally agree on this one, and it should also be possible to change layout per action. For example in Rails you can do it like this: class MyController < ApplicationController layout "main", only [:index] layout "admin", except [:index] ... end
Hide
Permalink
Jeff Brown added a comment - 16/Feb/09 6:17 PM

A layout may be specified by assigning a value to a static property named "layout" in a controller:

class BookController {
    static layout = 'customer'
}

Views rendered from that controller would be decorated with the grails-app/views/layouts/customer.gsp sitemesh template.

Show
Jeff Brown added a comment - 16/Feb/09 6:17 PM A layout may be specified by assigning a value to a static property named "layout" in a controller: class BookController { static layout = 'customer' } Views rendered from that controller would be decorated with the grails-app/views/layouts/customer.gsp sitemesh template.

People

  • Assignee:
    Jeff Brown
    Reporter:
    kris helenek
Vote (0)
Watch (0)

Dates

  • Created:
    06/Dec/07 10:40 AM
    Updated:
    16/Feb/09 6:17 PM
    Resolved:
    16/Feb/09 6:17 PM

Agile

  • View on Board
  • Atlassian JIRA (v5.2.1#813-sha1:277a546)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Grails project. Try JIRA - bug tracking software for your team.