You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jason Deffenbaugh <jd...@techtarget.com> on 2007/10/08 18:59:20 UTC
Struts 2 Freemarker Templates
I'm trying to make a custom template for the checkboxlist struts tag to
only write out the html for the checkboxes in the list between two
parameter values I send to the template.
I want to pass parameters from the jsp file into the freemarker template
but I'm not sure how to do it.
So, I'm thinking that in the jsp I do something like:
<s:checkboxlist name="x" list="myList" template="mycheckboxlist"
templateDir="WEB-INF/freemarker">
<s:param name="start" value="%{2}"/>
<s:param name="stop" value="%{4}"/>
</s:checkboxlist>
Can I access that in the template somehow?
Thanks,
Jason
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Struts 2 Themes
Posted by "Jiang, Jane (NIH/NCI) [C]" <ji...@mail.nih.gov>.
Thank you, Sami. That helps a lot.
Jane
-----Original Message-----
From: Sami Dalouche [mailto:skoobi@free.fr]
Sent: Tuesday, October 09, 2007 1:55 PM
To: Struts Users Mailing List
Subject: RE: Struts 2 Themes
Hi,
your best bet is to look at S2's source code. You can start by looking
at org.apache.struts2.views.freemarker.tags.StrutsModels.
Each of the tags have an associated "Model", and S2 taglib's models are
registered in this class.
So, for instance, if you look for TextField's template name :
1] There is a "TextFieldModel" instance declared
2] So, you look at
org.apache.struts2.views.freemarker.tags.TextFieldModel#getBean() :
3] You can see "return new TextField(stack, req, res);"
4] So, you look at org.apache.struts2.components.TextField
5] You can see : final public static String TEMPLATE = "text";
=> So, the template name is "text" ;)
Regards,
Sami Dalouche
Le mardi 09 octobre 2007 à 13:07 -0400, Jiang, Jane (NIH/NCI) [C] a
écrit :
> Sorry, my fault. I did not notice the code I used to test checkbox
> defined the theme inside the tag. So checkbox.ftl is the template for
> s:checkbox. I would still like to find out if there is a general rule
> for map the tag to template and other resource to learn about theme.
>
> -----Original Message-----
> From: Jiang, Jane (NIH/NCI) [C]
> Sent: Tuesday, October 09, 2007 12:57 PM
> To: Struts Users Mailing List
> Subject: Struts 2 Themes
>
> I am trying to get a better understanding of S2 themes. I read the
> document and the create themes page in the cookbook.
>
> My question is how I can find the right template file for a tag. I
> tried to change text.ftl and found that ties to s:textfield. I am now
> trying to figure out what is the one for checkbox. I thought it would
> be the checkbox.ftl. But s:chechbox does not change at all when I
> changed the checkbox.ftl. What about s:property?
>
> Where can I find more information if I want to get more into the themes?
>
> Thanks a lot for your help,
>
> Jane
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Struts 2 Themes
Posted by Sami Dalouche <sk...@free.fr>.
Hi,
your best bet is to look at S2's source code. You can start by looking
at org.apache.struts2.views.freemarker.tags.StrutsModels.
Each of the tags have an associated "Model", and S2 taglib's models are
registered in this class.
So, for instance, if you look for TextField's template name :
1] There is a "TextFieldModel" instance declared
2] So, you look at
org.apache.struts2.views.freemarker.tags.TextFieldModel#getBean() :
3] You can see "return new TextField(stack, req, res);"
4] So, you look at org.apache.struts2.components.TextField
5] You can see : final public static String TEMPLATE = "text";
=> So, the template name is "text" ;)
Regards,
Sami Dalouche
Le mardi 09 octobre 2007 à 13:07 -0400, Jiang, Jane (NIH/NCI) [C] a
écrit :
> Sorry, my fault. I did not notice the code I used to test checkbox
> defined the theme inside the tag. So checkbox.ftl is the template for
> s:checkbox. I would still like to find out if there is a general rule
> for map the tag to template and other resource to learn about theme.
>
> -----Original Message-----
> From: Jiang, Jane (NIH/NCI) [C]
> Sent: Tuesday, October 09, 2007 12:57 PM
> To: Struts Users Mailing List
> Subject: Struts 2 Themes
>
> I am trying to get a better understanding of S2 themes. I read the
> document and the create themes page in the cookbook.
>
> My question is how I can find the right template file for a tag. I
> tried to change text.ftl and found that ties to s:textfield. I am now
> trying to figure out what is the one for checkbox. I thought it would
> be the checkbox.ftl. But s:chechbox does not change at all when I
> changed the checkbox.ftl. What about s:property?
>
> Where can I find more information if I want to get more into the themes?
>
> Thanks a lot for your help,
>
> Jane
>
> ---------------------------------------------------------------------
> 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: Struts 2 Themes
Posted by "Jiang, Jane (NIH/NCI) [C]" <ji...@mail.nih.gov>.
Sorry, my fault. I did not notice the code I used to test checkbox
defined the theme inside the tag. So checkbox.ftl is the template for
s:checkbox. I would still like to find out if there is a general rule
for map the tag to template and other resource to learn about theme.
-----Original Message-----
From: Jiang, Jane (NIH/NCI) [C]
Sent: Tuesday, October 09, 2007 12:57 PM
To: Struts Users Mailing List
Subject: Struts 2 Themes
I am trying to get a better understanding of S2 themes. I read the
document and the create themes page in the cookbook.
My question is how I can find the right template file for a tag. I
tried to change text.ftl and found that ties to s:textfield. I am now
trying to figure out what is the one for checkbox. I thought it would
be the checkbox.ftl. But s:chechbox does not change at all when I
changed the checkbox.ftl. What about s:property?
Where can I find more information if I want to get more into the themes?
Thanks a lot for your help,
Jane
---------------------------------------------------------------------
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
Struts 2 Themes
Posted by "Jiang, Jane (NIH/NCI) [C]" <ji...@mail.nih.gov>.
I am trying to get a better understanding of S2 themes. I read the
document and the create themes page in the cookbook.
My question is how I can find the right template file for a tag. I
tried to change text.ftl and found that ties to s:textfield. I am now
trying to figure out what is the one for checkbox. I thought it would
be the checkbox.ftl. But s:chechbox does not change at all when I
changed the checkbox.ftl. What about s:property?
Where can I find more information if I want to get more into the themes?
Thanks a lot for your help,
Jane
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts 2 Freemarker Templates
Posted by Jason Deffenbaugh <jd...@techtarget.com>.
Thanks that helped/worked.
I got it working using
<#if (itemCount == parameters.stop)></#if>
to access the custom parameters.
-Jason
On Mon, 2007-10-08 at 19:47 +0200, Sami Dalouche wrote:
> Hi,
>
> you should be able to access your start and stop variables using :
>
> ${parameters.start} and ${parameters.stop} expressions in your FTL
> template.
>
> Regards,
> Sami Dalouche
>
> Le lundi 08 octobre 2007 à 12:59 -0400, Jason Deffenbaugh a écrit :
> > I'm trying to make a custom template for the checkboxlist struts tag to
> > only write out the html for the checkboxes in the list between two
> > parameter values I send to the template.
> >
> > I want to pass parameters from the jsp file into the freemarker template
> > but I'm not sure how to do it.
> >
> >
> > So, I'm thinking that in the jsp I do something like:
> >
> > <s:checkboxlist name="x" list="myList" template="mycheckboxlist"
> > templateDir="WEB-INF/freemarker">
> > <s:param name="start" value="%{2}"/>
> > <s:param name="stop" value="%{4}"/>
> > </s:checkboxlist>
> >
> > Can I access that in the template somehow?
> >
> > Thanks,
> > Jason
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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: Struts 2 Freemarker Templates
Posted by Sami Dalouche <sk...@free.fr>.
Hi,
you should be able to access your start and stop variables using :
${parameters.start} and ${parameters.stop} expressions in your FTL
template.
Regards,
Sami Dalouche
Le lundi 08 octobre 2007 à 12:59 -0400, Jason Deffenbaugh a écrit :
> I'm trying to make a custom template for the checkboxlist struts tag to
> only write out the html for the checkboxes in the list between two
> parameter values I send to the template.
>
> I want to pass parameters from the jsp file into the freemarker template
> but I'm not sure how to do it.
>
>
> So, I'm thinking that in the jsp I do something like:
>
> <s:checkboxlist name="x" list="myList" template="mycheckboxlist"
> templateDir="WEB-INF/freemarker">
> <s:param name="start" value="%{2}"/>
> <s:param name="stop" value="%{4}"/>
> </s:checkboxlist>
>
> Can I access that in the template somehow?
>
> Thanks,
> Jason
>
>
>
>
> ---------------------------------------------------------------------
> 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