You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by me <ml...@e-beyond.de> on 2008/03/28 08:14:20 UTC

S2/Sitemesh: How to set the title in a freemarker template?

Hi,

I'm running struts2 with sitemesh. There is a freemarker template 
defined in the decorators and this template
has both variables $title and $body. The body is filled autmatically 
which is okay. But I want to set the title
from the action I've called because I wanted to have the content and the 
title having a relation to each other
(which makes sense, I believe... :) )

Thanks for your help.

Marc

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


Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by me <ml...@e-beyond.de>.
May be. I haven't done anything with struts 2 and sitemesh until now. 
Mostly I had worked with struts 1 but
I had to upgrade now.... (So I'm still a beginner. :) )

stanlick@gmail.com schrieb:
> Dude, do you sleep?
>
> On Fri, Mar 28, 2008 at 5:09 AM, me <ml...@e-beyond.de> wrote:
>
>   


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


Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by st...@gmail.com.
Dude, do you sleep?

On Fri, Mar 28, 2008 at 5:09 AM, me <ml...@e-beyond.de> wrote:

> Great! It works perfectly!
>
> Thank you very much!!!
>
> Marc
>
> stanlick@gmail.com schrieb:
> > Try stack.findString('title') instead of ${title}
> >
> > On Fri, Mar 28, 2008 at 4:57 AM, me <ml...@e-beyond.de> wrote:
> >
> >
> >> stanlick@gmail.com schrieb:
> >>
> >>> No problem bro
> >>>
> >>> Let's see what you added to your template to fetch the title from
> action
> >>>
> >> Okay, these are my files:
> >>
> >> template.ftl:
> >> --------------------------------------------------------------
> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> >> <html>
> >> <head>
> >>    <title>test - ${title}</title>
> >> </head>
> >> <body>
> >> ${body}
> >> </body>
> >> </html>
> >> --------------------------------------------------------------
> >>
> >> ContactAction:
> >> --------------------------------------------------------------
> >> package isi.services.pages;
> >>
> >> import com.opensymphony.xwork2.ActionSupport;
> >>
> >>
> >> public class ContactAction extends ActionSupport {
> >>
> >>  String title = "hallo";
> >>
> >>  public String execute() {
> >>    return "input";
> >>  }
> >>
> >>  public String getTitle() {
> >>    return this.title;
> >>  }
> >>
> >>  public void setTitle(final String value) {
> >>    this.title = value;
> >>  }
> >>
> >> }
> >> --------------------------------------------------------------
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>


-- 
Scott
stanlick@gmail.com

Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by me <ml...@e-beyond.de>.
Great! It works perfectly!

Thank you very much!!!

Marc

stanlick@gmail.com schrieb:
> Try stack.findString('title') instead of ${title}
>
> On Fri, Mar 28, 2008 at 4:57 AM, me <ml...@e-beyond.de> wrote:
>
>   
>> stanlick@gmail.com schrieb:
>>     
>>> No problem bro
>>>
>>> Let's see what you added to your template to fetch the title from action
>>>       
>> Okay, these are my files:
>>
>> template.ftl:
>> --------------------------------------------------------------
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> <html>
>> <head>
>>    <title>test - ${title}</title>
>> </head>
>> <body>
>> ${body}
>> </body>
>> </html>
>> --------------------------------------------------------------
>>
>> ContactAction:
>> --------------------------------------------------------------
>> package isi.services.pages;
>>
>> import com.opensymphony.xwork2.ActionSupport;
>>
>>
>> public class ContactAction extends ActionSupport {
>>
>>  String title = "hallo";
>>
>>  public String execute() {
>>    return "input";
>>  }
>>
>>  public String getTitle() {
>>    return this.title;
>>  }
>>
>>  public void setTitle(final String value) {
>>    this.title = value;
>>  }
>>
>> }
>> --------------------------------------------------------------
>>
>>
>> ---------------------------------------------------------------------
>> 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: S2/Sitemesh: How to set the title in a freemarker template?

Posted by st...@gmail.com.
Try stack.findString('title') instead of ${title}

On Fri, Mar 28, 2008 at 4:57 AM, me <ml...@e-beyond.de> wrote:

>
> stanlick@gmail.com schrieb:
> > No problem bro
> >
> > Let's see what you added to your template to fetch the title from action
> Okay, these are my files:
>
> template.ftl:
> --------------------------------------------------------------
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html>
> <head>
>    <title>test - ${title}</title>
> </head>
> <body>
> ${body}
> </body>
> </html>
> --------------------------------------------------------------
>
> ContactAction:
> --------------------------------------------------------------
> package isi.services.pages;
>
> import com.opensymphony.xwork2.ActionSupport;
>
>
> public class ContactAction extends ActionSupport {
>
>  String title = "hallo";
>
>  public String execute() {
>    return "input";
>  }
>
>  public String getTitle() {
>    return this.title;
>  }
>
>  public void setTitle(final String value) {
>    this.title = value;
>  }
>
> }
> --------------------------------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by me <ml...@e-beyond.de>.
stanlick@gmail.com schrieb:
> No problem bro
>
> Let's see what you added to your template to fetch the title from action
Okay, these are my files:

template.ftl:
--------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>test - ${title}</title>
</head>
<body>
${body}
</body>
</html>
--------------------------------------------------------------

ContactAction:
--------------------------------------------------------------
package isi.services.pages;

import com.opensymphony.xwork2.ActionSupport;


public class ContactAction extends ActionSupport {
 
  String title = "hallo";
 
  public String execute() {
    return "input";
  }
 
  public String getTitle() {
    return this.title;
  }

  public void setTitle(final String value) {
    this.title = value;
  }
 
}
--------------------------------------------------------------


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


Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by st...@gmail.com.
No problem bro

Let's see what you added to your template to fetch the title from action

On Fri, Mar 28, 2008 at 4:18 AM, me <ml...@e-beyond.de> wrote:

> Sorry but I think I miss something. I've got a action which extends
> ActionSupport. This Action has got an execute() method
> and an title property with the getters and setters.
> The action is properly read and executed. But the property wasn't. Is
> there anything I have to take care of?
> Sorry for my stupid questions.
>
> Marc
>
> stanlick@gmail.com schrieb:
> > The FreeMarker template can access the property in your action to get
> the
> > "action variable" title.
> >
> > On Fri, Mar 28, 2008 at 3:24 AM, me <ml...@e-beyond.de> wrote:
> >
> >
> >> Hi,
> >>
> >> hmmm... do you mean that I should create a template for each site which
> >> has another title?
> >> I think that would be too much. I've got several pages which should get
> >> a title based on information
> >> located in a database.
> >>
> >> I thought that there will be a property in the action i have to set or
> >> can I access the
> >> value-stack from the sitemesh-freemarker template?
> >>
> >>
> >> Marc
> >>
> >> stanlick@gmail.com schrieb:
> >>
> >>> Hey Marc --
> >>>
> >>> copy that FreeMarker template into your <webroot>/template folder and
> >>>
> >> modify
> >>
> >>> it with your desired changes.  Struts 2 will grab yours for rendering.
> >>>
> >>>
> >>> On Fri, Mar 28, 2008 at 2:14 AM, me <ml...@e-beyond.de> wrote:
> >>>
> >>>
> >>>
> >>>> Hi,
> >>>>
> >>>> I'm running struts2 with sitemesh. There is a freemarker template
> >>>> defined in the decorators and this template
> >>>> has both variables $title and $body. The body is filled autmatically
> >>>> which is okay. But I want to set the title
> >>>> from the action I've called because I wanted to have the content and
> >>>>
> >> the
> >>
> >>>> title having a relation to each other
> >>>> (which makes sense, I believe... :) )
> >>>>
> >>>> Thanks for your help.
> >>>>
> >>>> Marc
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> 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
> >>
> >>
> >>
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com

Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by me <ml...@e-beyond.de>.
Sorry but I think I miss something. I've got a action which extends 
ActionSupport. This Action has got an execute() method
and an title property with the getters and setters.
The action is properly read and executed. But the property wasn't. Is 
there anything I have to take care of?
Sorry for my stupid questions.

Marc

stanlick@gmail.com schrieb:
> The FreeMarker template can access the property in your action to get the
> "action variable" title.
>
> On Fri, Mar 28, 2008 at 3:24 AM, me <ml...@e-beyond.de> wrote:
>
>   
>> Hi,
>>
>> hmmm... do you mean that I should create a template for each site which
>> has another title?
>> I think that would be too much. I've got several pages which should get
>> a title based on information
>> located in a database.
>>
>> I thought that there will be a property in the action i have to set or
>> can I access the
>> value-stack from the sitemesh-freemarker template?
>>
>>
>> Marc
>>
>> stanlick@gmail.com schrieb:
>>     
>>> Hey Marc --
>>>
>>> copy that FreeMarker template into your <webroot>/template folder and
>>>       
>> modify
>>     
>>> it with your desired changes.  Struts 2 will grab yours for rendering.
>>>
>>>
>>> On Fri, Mar 28, 2008 at 2:14 AM, me <ml...@e-beyond.de> wrote:
>>>
>>>
>>>       
>>>> Hi,
>>>>
>>>> I'm running struts2 with sitemesh. There is a freemarker template
>>>> defined in the decorators and this template
>>>> has both variables $title and $body. The body is filled autmatically
>>>> which is okay. But I want to set the title
>>>> from the action I've called because I wanted to have the content and
>>>>         
>> the
>>     
>>>> title having a relation to each other
>>>> (which makes sense, I believe... :) )
>>>>
>>>> Thanks for your help.
>>>>
>>>> Marc
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>
>>
>>     
>
>
>   


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


Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by st...@gmail.com.
The FreeMarker template can access the property in your action to get the
"action variable" title.

On Fri, Mar 28, 2008 at 3:24 AM, me <ml...@e-beyond.de> wrote:

> Hi,
>
> hmmm... do you mean that I should create a template for each site which
> has another title?
> I think that would be too much. I've got several pages which should get
> a title based on information
> located in a database.
>
> I thought that there will be a property in the action i have to set or
> can I access the
> value-stack from the sitemesh-freemarker template?
>
>
> Marc
>
> stanlick@gmail.com schrieb:
> > Hey Marc --
> >
> > copy that FreeMarker template into your <webroot>/template folder and
> modify
> > it with your desired changes.  Struts 2 will grab yours for rendering.
> >
> >
> > On Fri, Mar 28, 2008 at 2:14 AM, me <ml...@e-beyond.de> wrote:
> >
> >
> >> Hi,
> >>
> >> I'm running struts2 with sitemesh. There is a freemarker template
> >> defined in the decorators and this template
> >> has both variables $title and $body. The body is filled autmatically
> >> which is okay. But I want to set the title
> >> from the action I've called because I wanted to have the content and
> the
> >> title having a relation to each other
> >> (which makes sense, I believe... :) )
> >>
> >> Thanks for your help.
> >>
> >> Marc
> >>
> >> ---------------------------------------------------------------------
> >> 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
>
>


-- 
Scott
stanlick@gmail.com

Re: S2/Sitemesh: How to set the title in a freemarker template?

Posted by me <ml...@e-beyond.de>.
Hi,

hmmm... do you mean that I should create a template for each site which 
has another title?
I think that would be too much. I've got several pages which should get 
a title based on information
located in a database.

I thought that there will be a property in the action i have to set or 
can I access the
value-stack from the sitemesh-freemarker template?


Marc

stanlick@gmail.com schrieb:
> Hey Marc --
>
> copy that FreeMarker template into your <webroot>/template folder and modify
> it with your desired changes.  Struts 2 will grab yours for rendering.
>
>
> On Fri, Mar 28, 2008 at 2:14 AM, me <ml...@e-beyond.de> wrote:
>
>   
>> Hi,
>>
>> I'm running struts2 with sitemesh. There is a freemarker template
>> defined in the decorators and this template
>> has both variables $title and $body. The body is filled autmatically
>> which is okay. But I want to set the title
>> from the action I've called because I wanted to have the content and the
>> title having a relation to each other
>> (which makes sense, I believe... :) )
>>
>> Thanks for your help.
>>
>> Marc
>>
>> ---------------------------------------------------------------------
>> 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: S2/Sitemesh: How to set the title in a freemarker template?

Posted by st...@gmail.com.
Hey Marc --

copy that FreeMarker template into your <webroot>/template folder and modify
it with your desired changes.  Struts 2 will grab yours for rendering.


On Fri, Mar 28, 2008 at 2:14 AM, me <ml...@e-beyond.de> wrote:

> Hi,
>
> I'm running struts2 with sitemesh. There is a freemarker template
> defined in the decorators and this template
> has both variables $title and $body. The body is filled autmatically
> which is okay. But I want to set the title
> from the action I've called because I wanted to have the content and the
> title having a relation to each other
> (which makes sense, I believe... :) )
>
> Thanks for your help.
>
> Marc
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Scott
stanlick@gmail.com