You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by hernan gonzalez <hg...@gmail.com> on 2008/03/28 19:28:53 UTC

s2: Including Freemarker templates from JSP

I have some freemarker templates (general purpose, i.e. not
specifically for struts2) that generate html fragments, which I would
like to include in some jsp pages (in a struts2 environment).

Which are my alternatives? At first I tought of making a general jsp

  <jsp:include page="includeFreemarkerS2.jsp">
       <jsp:param name="templateName" value="test/foo.ftl" />
  </jsp:include>

where includeFreemarkerS2.jsp invokes (with Java scriptlet) my already
working aplication logic that finds-parses-fills the template, getting
the datamodel from the corresponding scope. But I am not sure of how
to pass some datamodel that wraps the ValueStack to Freemarker. And I
suspect there must be a simpler and nicer solution.
Suggestions?

Hernán

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


Re: s2: Including Freemarker templates from JSP

Posted by hernan gonzalez <hg...@gmail.com>.
Thanks.
It is indeed almost sufficient.

The docs had led to me think the "params" were the only way to pass
parameters to the template, but in fact it works as it should without
any parameters, seeking the values in the value stack.

That's fine.

The only inconvenience is the rigid scheme for specifying the file
path: ${templateDir}/${theme}/${template}. And it doesnt accept an
empty theme.

Hernán J. González
http://hjg.com.ar/


On Sun, Mar 30, 2008 at 7:40 PM, Jeromy Evans
<je...@blueskyminds.com.au> wrote:
> The Struts2 Component tag may be sufficient:
>  http://struts.apache.org/2.x/docs/component.html
>
>
>
>  hernan gonzalez wrote:
>  > I have some freemarker templates (general purpose, i.e. not
>  > specifically for struts2) that generate html fragments, which I would
>  > like to include in some jsp pages (in a struts2 environment).
>  >
>  > Which are my alternatives? At first I tought of making a general jsp
>  >
>  >   <jsp:include page="includeFreemarkerS2.jsp">
>  >        <jsp:param name="templateName" value="test/foo.ftl" />
>  >   </jsp:include>
>  >
>  > where includeFreemarkerS2.jsp invokes (with Java scriptlet) my already
>  > working aplication logic that finds-parses-fills the template, getting
>  > the datamodel from the corresponding scope. But I am not sure of how
>  > to pass some datamodel that wraps the ValueStack to Freemarker. And I
>  > suspect there must be a simpler and nicer solution.
>  > Suggestions?
>  >
>  > Hernán
>  >
>  > ---------------------------------------------------------------------
>  > 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: Including Freemarker templates from JSP

Posted by hernan gonzalez <hg...@gmail.com>.
Thanks.
It is indeed almost sufficient.

The docs had led to me think the "params" were the only way to pass
parameters to the template, but in fact it works as it should without
any parameters, seeking the values in the value stack.

That's fine.

The only inconvenience is the rigid scheme for specifying the file
path: ${templateDir}/${theme}/${template}. And it doesnt accept an
empty theme.

Hernán J. González
http://hjg.com.ar/


On Sun, Mar 30, 2008 at 7:40 PM, Jeromy Evans
<je...@blueskyminds.com.au> wrote:
> The Struts2 Component tag may be sufficient:
>  http://struts.apache.org/2.x/docs/component.html
>
>
>
>  hernan gonzalez wrote:
>  > I have some freemarker templates (general purpose, i.e. not
>  > specifically for struts2) that generate html fragments, which I would
>  > like to include in some jsp pages (in a struts2 environment).
>  >
>  > Which are my alternatives? At first I tought of making a general jsp
>  >
>  >   <jsp:include page="includeFreemarkerS2.jsp">
>  >        <jsp:param name="templateName" value="test/foo.ftl" />
>  >   </jsp:include>
>  >
>  > where includeFreemarkerS2.jsp invokes (with Java scriptlet) my already
>  > working aplication logic that finds-parses-fills the template, getting
>  > the datamodel from the corresponding scope. But I am not sure of how
>  > to pass some datamodel that wraps the ValueStack to Freemarker. And I
>  > suspect there must be a simpler and nicer solution.
>  > Suggestions?
>  >
>  > Hernán
>  >
>  > ---------------------------------------------------------------------
>  > 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: Including Freemarker templates from JSP

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
The Struts2 Component tag may be sufficient: 
http://struts.apache.org/2.x/docs/component.html

hernan gonzalez wrote:
> I have some freemarker templates (general purpose, i.e. not
> specifically for struts2) that generate html fragments, which I would
> like to include in some jsp pages (in a struts2 environment).
>
> Which are my alternatives? At first I tought of making a general jsp
>
>   <jsp:include page="includeFreemarkerS2.jsp">
>        <jsp:param name="templateName" value="test/foo.ftl" />
>   </jsp:include>
>
> where includeFreemarkerS2.jsp invokes (with Java scriptlet) my already
> working aplication logic that finds-parses-fills the template, getting
> the datamodel from the corresponding scope. But I am not sure of how
> to pass some datamodel that wraps the ValueStack to Freemarker. And I
> suspect there must be a simpler and nicer solution.
> Suggestions?
>
> Hernán
>
> ---------------------------------------------------------------------
> 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