Hello,
I very often face a situation that causes me troubles. I basically
wish to render pages that will have a common layout, and only their
general content will differ. One could think Sitemesh should be used
for writing the layout, and the content of the pages should be broken
into various GSP views. The problem is that it is hard to use Sitemesh
because the layout uses objects for rendering, and since the Hibernate
session is not active when Sitemesh output is rendered, this makes it
*extremely* cumbersome to use Sitemesh, since you have to be really
careful for LazyInitialization Hibernate exceptions.
A second thing I don't like with Sitemesh is that you have only "one
place" that can change, eg the <body> tag. Quite often, my views would
have two areas that need to be injected back into the Sitemesh layout,
and I cannot do that (someone please prove me wrong if I am).
I feel there is room for a big improvement in this area. I'd like to
hear people advices about this, because I may be ignoring a convenient
way to achieve what I need. But if there is no current way to solve
the problems I was outlining, here are my suggestions:
* Make the OpenSessionInView interceptor also works when rendering
Sitemesh layouts (I think this was already discussed). Note that this
may have drawbacks (performance, I dont know), and does not solve the
second problem I have;
* Develop a tag that basically does the reverse of g.render. g.render
is absolutely essential (without it GSP would be really limited), and
I really feel the reverse tag is needed. Eg, a tag that tells that the
contents of the tag should be included within another page that is to
be rendered. We should be able to specify the place where it should be
rendered in the parent layout, thus working around Sitemesh
limitations that I described (as an added bonus, since the layout
would be truely a GSP page, I guess the OpenSessionInView issues would
not apply).
Something that would like that:
<g:renderLayout layout="myLayout.gsp">
<g:include place="myDivIdentifier"> <!-- we should be able to specify
the place where this is include via a tag name or tag attribute !-->
<p>My interesting content.</p>
</g:include>
<g:include place="myDivIdentifier2">
<p>Another content that goes into a different place.</p>
</g:include>
</g:renderLayout>
The second solution does not seem too hard - Grails developers, what
do you think?
Maybe what I want is already possible through a plugin to Grails view
technologies (did not look at them, but will do), but, IMHO, this
should be part of GSP.
Jean-Noel
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email