Quantcast

Naming of templates and controllers with AJAX

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

Naming of templates and controllers with AJAX

rothen
I just stumbled across an ugly little technicality of grails: Don't give a template in the layout directory the same name as a controller, especially if you work with AJAX calls that render only a part of a page. It seems that every action in a controller loads a template with the same name if it finds one. With an AJAX request this just doubles your template elements. It seems that this feature is intentional, it is called layout-by-convention.

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

Re: Naming of templates and controllers

Jeff Brown-3
On Mon, Aug 31, 2009 at 2:49 PM, rothen<[hidden email]> wrote:

>
> I just stumbled across an ugly little technicality of grails: Don't give a
> template in the layout directory the same name as a controller, especially
> if you work with AJAX calls that render only a part of a page. It seems that
> every action in a controller loads a template with the same name if it finds
> one. With an AJAX request this just doubles your template elements. I'm not
> sure whether this is intentional or whether it is a bug.
>
> http://www.nabble.com/file/p25229392/grails_layouts_e.jpg
> --

It is intentional.  In section 6.2.4 of The User Guide
(http://grails.org/doc/latest/) under the "Layout by Convention"
heading...

"You can create a layout called grails-app/views/layouts/customer.gsp
which will be applied to all views that the BookController delegates
to."



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


Loading...