Quantcast

Specific layout for controller...

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Specific layout for controller...

webmediauk
Hey Guys,
I've got the following lines in my controller, however the views from this controller all still render using "main.gsp" as their layout?
Any ideas why this happens?

class VoidController {
    static layout = 'admin'
    static scaffold = true
    //def index = { }
}

Many Thanks
Baz
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Specific layout for controller...

chichibek bros
is the admin.gsp layout in the root of layout directory?

i paste here a bit of information about sitemesh trough controllers it can help you.

Specifying A Layout In A Controller

Another way to specify a layout is to specify the name of the layout by assigning a value to the "layout" property in a controller. For example, if you have a controller such as:

class BookController {
    static layout = 'customer'

def list() { … } }

You can create a layout called grails-app/views/layouts/customer.gsp which will be applied to all views that the BookController delegates to. The value of the "layout" property may contain a directory structure relative to the grails-app/views/layouts/ directory. For example:

class BookController { static layout = 'custom/customer'

def list() { … } }

more information: http://grails.org/doc/latest/guide/theWebLayer.html#layouts




2012/6/28 webmediauk <[hidden email]>
Hey Guys,
I've got the following lines in my controller, however the views from this
controller all still render using "main.gsp" as their layout?
Any ideas why this happens?

class VoidController {
   static layout = 'admin'
   static scaffold = true
   //def index = { }
}

Many Thanks
Baz

--
View this message in context: http://grails.1312388.n4.nabble.com/Specific-layout-for-controller-tp4630793.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Specific layout for controller...

Jeff Brown-3
In reply to this post by webmediauk
webmediauk wrote:

> Hey Guys,
> I've got the following lines in my controller, however the views from this
> controller all still render using "main.gsp" as their layout?
> Any ideas why this happens?
>
> class VoidController {
>      static layout = 'admin'
>      static scaffold = true
>      //def index = { }
> }
>
> Many Thanks
> Baz
>

Do the views in question have a meta tag in them that requests the
"main" layout?



jb


--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Specific layout for controller...

webmediauk
Hey Jeff,
I haven't had a chance to read chicibek bros' suggestion yet but there are no gsp's in question as the controller is scaffolded at runtime.
Thanks
Baz
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Specific layout for controller...

Jeff Brown-3
webmediauk wrote:

> Hey Jeff,
> I haven't had a chance to read chicibek bros' suggestion yet but there are
> no gsp's in question as the controller is scaffolded at runtime.
> Thanks
> Baz
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Specific-layout-for-controller-tp4630793p4630874.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>

That might be the problem.  I haven't tested but it may be that the
declarative layout expression ("static layout = "admin") is broken for
dynamically scaffolded views.  If that is it, please raise a JIRA.



jb
--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Specific layout for controller...

webmediauk
Jeff Brown-3 wrote
That might be the problem.  I haven't tested but it may be that the
declarative layout expression ("static layout = "admin") is broken for
dynamically scaffolded views.  If that is it, please raise a JIRA.
Hey Jeff,
Sure enough as soon as I actually created the GSP's the admin layout was used.
Is there a way to set the default layout to use? I think throughout the rest of my application I have generated GSP's! I just don't want to here if I can help it.
Many Thanks
Barry
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Specific layout for controller...

Jeff Brown-3
webmediauk wrote:

> Jeff Brown-3 wrote
>> That might be the problem.  I haven't tested but it may be that the
>> declarative layout expression ("static layout = "admin") is broken for
>> dynamically scaffolded views.  If that is it, please raise a JIRA.
>>
>
> Hey Jeff,
> Sure enough as soon as I actually created the GSP's the admin layout was
> used.
> Is there a way to set the default layout to use? I think throughout the rest
> of my application I have generated GSP's! I just don't want to here if I can
> help it.
> Many Thanks
> Barry
>
>


I haven't tested it myself but it sounds like "static layout=foo" in a
controller just isn't working for dynamically scaffolded views.  One
could argue if that is a bug or a feature that just hasn't been
implemented (I would probably call it a bug), but in either case we can
look at it and try to make it work.  If you care to open a JIRA that
will make sure that it is tracked and probably implemented.

If all of your dynamically scaffolded views use the same layout then you
would have at least a couple of options.  You could change your main.gsp
to have whatever those views need.  You could install the scaffolding
templates (grails install-templates) and modify the default scaffolded
views to do whatever you need them to do.

I hope that helps.



jb


--
Jeff Brown
SpringSource
http://www.springsource.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Specific layout for controller...

webmediauk
Hey Jeff,
I think this might be the same issue?

http://jira.grails.org/browse/GRAILS-7013

Many Thanks
Barry
Loading...