You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pascal <pa...@voidmage.net> on 2009/07/17 22:01:37 UTC

Tags as template parameters?

Hello list,

in Struts2 it is possible to do something like

<html>
<body>
  <s:myMainNavigationMenu />

  <h1>A page</h1>
  <p>Some content</p>
</body>
</html>

This works ok, but my problem is that I have to change every single
page, if i would like to have a custom footer for every page, for example.

Now my question is: Is it possible to do something like this?

<s:useTemplate name="myCommonTemplate">
    <s:setTemplateTag name="body">
        <h1>A page</h1>
        <p>Some content</p>
    </s:setTemplateTag>
</s:useTemplate>

And as template definition say

<!-- Main menu -->
<table>...</table>

<s:insertTemplateTag name="body" />

<!-- Footer -->
<p>This is the footer</p>

I know it is possible to use parameters for templates, but they
obviously have huge limitations as I can't just put the tags there as I
did in my example.

Also, I could do something like

<s:myMainTemplate>
<s:param name="bodyPage" value="page1.jsp" />
</s:myMainTemplate>

which I also don't want because I would have an extra (unnecessary) page.

So, is it possible to pass whole XML-Structures to templates? Maybe you
have some reasons why I shouldn't want what I'm suggesting here, I would
be eager to hear them! :-)

Pascal

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tags as template parameters?

Posted by Paul Benedict <pb...@apache.org>.
Dave,

You're a valuable resource to the Struts board! Pascal should pay
attention to what you say.

Paul

On Mon, Jul 20, 2009 at 4:15 PM, Kawczynski, David wrote:
> Sitemesh doesn't build the entire page... it is a Filter that grabs the
> response text (immediately before the servlet container sends it to the
> client) and adds to it.  Decorators contain what is added to the
> response.  I've found that if your decorators require a lot of run-time
> logic then yes, it will take more time then if it were never modified.
> (Exactly how much time depends on the decorator's logic.)  Otherwise,
> the time to decorate a page is negligible.  Be smart when writing your
> decorators... for instance, mapping different decorators to the
> diverging URI patterns is an easy way to avoid the time penalty
> associated with logic in decorators.
>
> HTH,
> -dave
>
>
>> -----Original Message-----
>> From: Pascal [mailto:pascal@voidmage.net]
>> Sent: Sunday, July 19, 2009 8:13 AM
>> To: Struts Users Mailing List
>> Subject: Re: Tags as template parameters?
>>
>> I just had a look at Sitemesh and it looks like what I want.
>> There is one
>> thing that disturbs me, though, it looks as if sitemesh will
>> build the page
>> every request, which causes quite some overhead, or am I
>> mistaken there?
>>
>> Pascal
>>
>> On Fri, 17 Jul 2009 20:44:59 -0400, Wes Wannemacher <we...@wantii.com>
>> wrote:
>> > I'm on my phone so I only skimmed your message. If I read correctly,
>> > you should take a look at sitemesh.
>> >
>> > -W
>> >
>> > On 7/17/09, Pascal <pa...@voidmage.net> wrote:
>> >> Hello list,
>> >>
>> >> in Struts2 it is possible to do something like
>> >>
>> >> <html>
>> >> <body>
>> >>   <s:myMainNavigationMenu />
>> >>
>> >>   <h1>A page</h1>
>> >>   <p>Some content</p>
>> >> </body>
>> >> </html>
>> >>
>> >> This works ok, but my problem is that I have to change every single
>> >> page, if i would like to have a custom footer for every page, for
>> >> example.
>> >>
>> >> Now my question is: Is it possible to do something like this?
>> >>
>> >> <s:useTemplate name="myCommonTemplate">
>> >>     <s:setTemplateTag name="body">
>> >>         <h1>A page</h1>
>> >>         <p>Some content</p>
>> >>     </s:setTemplateTag>
>> >> </s:useTemplate>
>> >>
>> >> And as template definition say
>> >>
>> >> <!-- Main menu -->
>> >> <table>...</table>
>> >>
>> >> <s:insertTemplateTag name="body" />
>> >>
>> >> <!-- Footer -->
>> >> <p>This is the footer</p>
>> >>
>> >> I know it is possible to use parameters for templates, but they
>> >> obviously have huge limitations as I can't just put the
>> tags there as I
>> >> did in my example.
>> >>
>> >> Also, I could do something like
>> >>
>> >> <s:myMainTemplate>
>> >> <s:param name="bodyPage" value="page1.jsp" />
>> >> </s:myMainTemplate>
>> >>
>> >> which I also don't want because I would have an extra (unnecessary)
>> page.
>> >>
>> >> So, is it possible to pass whole XML-Structures to
>> templates? Maybe you
>> >> have some reasons why I shouldn't want what I'm suggesting
>> here, I would
>> >> be eager to hear them! :-)
>> >>
>> >> Pascal
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> Notice:  This e-mail message, together with any attachments, contains
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
> New Jersey, USA 08889), and/or its affiliates (which may be known
> outside the United States as Merck Frosst, Merck Sharp & Dohme or
> MSD and in Japan, as Banyu - direct contact information for affiliates is
> available at http://www.merck.com/contact/contacts.html) that may be
> confidential, proprietary copyrighted and/or legally privileged. It is
> intended solely for the use of the individual or entity named on this
> message. If you are not the intended recipient, and have received this
> message in error, please notify us immediately by reply e-mail and
> then delete it from your system.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Tags as template parameters?

Posted by "Kawczynski, David" <da...@merck.com>.
Sitemesh doesn't build the entire page... it is a Filter that grabs the
response text (immediately before the servlet container sends it to the
client) and adds to it.  Decorators contain what is added to the
response.  I've found that if your decorators require a lot of run-time
logic then yes, it will take more time then if it were never modified.
(Exactly how much time depends on the decorator's logic.)  Otherwise,
the time to decorate a page is negligible.  Be smart when writing your
decorators... for instance, mapping different decorators to the
diverging URI patterns is an easy way to avoid the time penalty
associated with logic in decorators.  

HTH,
-dave


> -----Original Message-----
> From: Pascal [mailto:pascal@voidmage.net] 
> Sent: Sunday, July 19, 2009 8:13 AM
> To: Struts Users Mailing List
> Subject: Re: Tags as template parameters?
> 
> I just had a look at Sitemesh and it looks like what I want. 
> There is one
> thing that disturbs me, though, it looks as if sitemesh will 
> build the page
> every request, which causes quite some overhead, or am I 
> mistaken there?
> 
> Pascal
> 
> On Fri, 17 Jul 2009 20:44:59 -0400, Wes Wannemacher <we...@wantii.com>
> wrote:
> > I'm on my phone so I only skimmed your message. If I read correctly,
> > you should take a look at sitemesh.
> > 
> > -W
> > 
> > On 7/17/09, Pascal <pa...@voidmage.net> wrote:
> >> Hello list,
> >>
> >> in Struts2 it is possible to do something like
> >>
> >> <html>
> >> <body>
> >>   <s:myMainNavigationMenu />
> >>
> >>   <h1>A page</h1>
> >>   <p>Some content</p>
> >> </body>
> >> </html>
> >>
> >> This works ok, but my problem is that I have to change every single
> >> page, if i would like to have a custom footer for every page, for
> >> example.
> >>
> >> Now my question is: Is it possible to do something like this?
> >>
> >> <s:useTemplate name="myCommonTemplate">
> >>     <s:setTemplateTag name="body">
> >>         <h1>A page</h1>
> >>         <p>Some content</p>
> >>     </s:setTemplateTag>
> >> </s:useTemplate>
> >>
> >> And as template definition say
> >>
> >> <!-- Main menu -->
> >> <table>...</table>
> >>
> >> <s:insertTemplateTag name="body" />
> >>
> >> <!-- Footer -->
> >> <p>This is the footer</p>
> >>
> >> I know it is possible to use parameters for templates, but they
> >> obviously have huge limitations as I can't just put the 
> tags there as I
> >> did in my example.
> >>
> >> Also, I could do something like
> >>
> >> <s:myMainTemplate>
> >> <s:param name="bodyPage" value="page1.jsp" />
> >> </s:myMainTemplate>
> >>
> >> which I also don't want because I would have an extra (unnecessary)
> page.
> >>
> >> So, is it possible to pass whole XML-Structures to 
> templates? Maybe you
> >> have some reasons why I shouldn't want what I'm suggesting 
> here, I would
> >> be eager to hear them! :-)
> >>
> >> Pascal
> >>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or
MSD and in Japan, as Banyu - direct contact information for affiliates is
available at http://www.merck.com/contact/contacts.html) that may be
confidential, proprietary copyrighted and/or legally privileged. It is
intended solely for the use of the individual or entity named on this
message. If you are not the intended recipient, and have received this
message in error, please notify us immediately by reply e-mail and
then delete it from your system.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tags as template parameters?

Posted by Pascal <pa...@voidmage.net>.
I just had a look at Sitemesh and it looks like what I want. There is one
thing that disturbs me, though, it looks as if sitemesh will build the page
every request, which causes quite some overhead, or am I mistaken there?

Pascal

On Fri, 17 Jul 2009 20:44:59 -0400, Wes Wannemacher <we...@wantii.com>
wrote:
> I'm on my phone so I only skimmed your message. If I read correctly,
> you should take a look at sitemesh.
> 
> -W
> 
> On 7/17/09, Pascal <pa...@voidmage.net> wrote:
>> Hello list,
>>
>> in Struts2 it is possible to do something like
>>
>> <html>
>> <body>
>>   <s:myMainNavigationMenu />
>>
>>   <h1>A page</h1>
>>   <p>Some content</p>
>> </body>
>> </html>
>>
>> This works ok, but my problem is that I have to change every single
>> page, if i would like to have a custom footer for every page, for
>> example.
>>
>> Now my question is: Is it possible to do something like this?
>>
>> <s:useTemplate name="myCommonTemplate">
>>     <s:setTemplateTag name="body">
>>         <h1>A page</h1>
>>         <p>Some content</p>
>>     </s:setTemplateTag>
>> </s:useTemplate>
>>
>> And as template definition say
>>
>> <!-- Main menu -->
>> <table>...</table>
>>
>> <s:insertTemplateTag name="body" />
>>
>> <!-- Footer -->
>> <p>This is the footer</p>
>>
>> I know it is possible to use parameters for templates, but they
>> obviously have huge limitations as I can't just put the tags there as I
>> did in my example.
>>
>> Also, I could do something like
>>
>> <s:myMainTemplate>
>> <s:param name="bodyPage" value="page1.jsp" />
>> </s:myMainTemplate>
>>
>> which I also don't want because I would have an extra (unnecessary)
page.
>>
>> So, is it possible to pass whole XML-Structures to templates? Maybe you
>> have some reasons why I shouldn't want what I'm suggesting here, I would
>> be eager to hear them! :-)
>>
>> Pascal
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tags as template parameters?

Posted by Wes Wannemacher <we...@wantii.com>.
I'm on my phone so I only skimmed your message. If I read correctly,
you should take a look at sitemesh.

-W

On 7/17/09, Pascal <pa...@voidmage.net> wrote:
> Hello list,
>
> in Struts2 it is possible to do something like
>
> <html>
> <body>
>   <s:myMainNavigationMenu />
>
>   <h1>A page</h1>
>   <p>Some content</p>
> </body>
> </html>
>
> This works ok, but my problem is that I have to change every single
> page, if i would like to have a custom footer for every page, for example.
>
> Now my question is: Is it possible to do something like this?
>
> <s:useTemplate name="myCommonTemplate">
>     <s:setTemplateTag name="body">
>         <h1>A page</h1>
>         <p>Some content</p>
>     </s:setTemplateTag>
> </s:useTemplate>
>
> And as template definition say
>
> <!-- Main menu -->
> <table>...</table>
>
> <s:insertTemplateTag name="body" />
>
> <!-- Footer -->
> <p>This is the footer</p>
>
> I know it is possible to use parameters for templates, but they
> obviously have huge limitations as I can't just put the tags there as I
> did in my example.
>
> Also, I could do something like
>
> <s:myMainTemplate>
> <s:param name="bodyPage" value="page1.jsp" />
> </s:myMainTemplate>
>
> which I also don't want because I would have an extra (unnecessary) page.
>
> So, is it possible to pass whole XML-Structures to templates? Maybe you
> have some reasons why I shouldn't want what I'm suggesting here, I would
> be eager to hear them! :-)
>
> Pascal
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org