You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Slonim, Greg (USAEO)" <Gr...@usdoj.gov> on 2009/09/18 19:09:31 UTC

FreeMarker Tags Help - setup

Hello,

Setup: struts2 (2.1.6) with Spring (2.5)

I Refer to the article in the docs 

http://struts.apache.org/2.1.6/docs/freemarker-tags.html

We are trying to use FreeMarker tags with a custom theme in order to
pass extra parameters to the tag which the tag does not define (section
of the above doc "Using inline attributes with templates")

When I attempt to use the markup 

<@s.form action="updatePerson">
    <@s.textfield label="First name" name="firstName"
extraParamName="blah"/>
    <@s.submit value="Update"/>
</...@s.form>

The JSP does not recognize this as a tag at all; all of the above is
printed to HTML verbatim. Is there anything I need to do, namespace
definition, etc. to make the engine understand that I use tags and not
literals? I understand that FreeMarker tags are extensions that are
shipped with default Struts distro, right?

Thank you very much

Greg


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


RE: FreeMarker Tags Help - setup

Posted by "Slonim, Greg (USAEO)" <Gr...@usdoj.gov>.
Hello and thank you for help. FYI for everyone

Struts 2.1.6 uses a new set of filters (see showcase app) instead of old
FilterDispatcher and cleanup. According to this
(http://www.nabble.com/Struts-2.1.6%2C-Sitemesh---FreeMarkerPageFilter-t
o21739507.html#a21789128)

Mushachy recommends using new filters. I did try that, but it seem to
conflict to my Conversation Scope interceptor (something that sits
between session and request and keeps conversation going). I have not
yet been able to use FreeMarker tags inside the JSP.

Thank you again

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: Friday, September 18, 2009 3:38 PM
To: Struts Users Mailing List
Subject: RE: FreeMarker Tags Help - setup


Good Afternoon Greg

here is an example of forms using freemarker templates in
chat\chatLogin.ftl
<html>
    <head>
        <title>Showcase - Chat - Login</title>
        <@s.head />
    </head>
    <body>
    <@s.actionerror />
    <@s.actionmessage />
    <@s.fielderror />
    <@s.form action="login" namespace="/chat" method="POST">
        <@s.textfield name="name" label="Name" required="true" />
        <@s.submit/>
    </...@s.form>
    </body>
</html>

//in order for the container to render this script one needs to define
the FreemarkerPageFilter in web.xml
//here is mine (transcribed from showcase/WEB-INF/web.xml)

    <!-- SNIPPET START: example.freemarker.filter.chain
    <filter>
        <filter-name>struts-cleanup</filter-name>
 
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter
-class>
    </filter>
    <filter>
        <filter-name>sitemesh</filter-name>
 
<filter-class>org.apache.struts2.sitemesh.FreeMarkerPageFilter</filter-c
lass>
    </filter>
    <filter>
        <filter-name>struts</filter-name>
 
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-cla
ss>
    </filter>

    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    END SNIPPET: example.freemarker.filter.chain -->

//BTW my non-xhtml (simple theme) ftl files are located in
//struts2-showcase-2.1.6\WEB-INF\classes\template\simple

//my xhtml ftl files are located on 
//struts2-showcase-2.1.6\WEB-INF\classes\template\xhtml

//the location of this folder are resolved by 3 parameters defined in
/org/apache/struts2/default.properties
### Standard UI theme
### Change this to reflect which path should be used for JSP control tag
templates by default
struts.ui.theme=simple

####location of template dir
struts.ui.templateDir=template

#sets the default template type. Either ftl, vm, or jsp
struts.ui.templateSuffix=ftlthis is one solution and I am sure there
other available solutions from the group monitoring this list

Does this help?
Martin Gainty 
______________________________________________ 
Disclaimer and Confidentiality Notice
Please be respectful of the rights of transmitter and recipient and do
not alter/modify or obstruct this transmission. Thank You




> Subject: FreeMarker Tags Help - setup
> Date: Fri, 18 Sep 2009 13:09:31 -0400
> From: Greg.Slonim@usdoj.gov
> To: user@struts.apache.org
> 
> Hello,
> 
> Setup: struts2 (2.1.6) with Spring (2.5)
> 
> I Refer to the article in the docs 
> 
> http://struts.apache.org/2.1.6/docs/freemarker-tags.html
> 
> We are trying to use FreeMarker tags with a custom theme in order to
> pass extra parameters to the tag which the tag does not define
(section
> of the above doc "Using inline attributes with templates")
> 
> When I attempt to use the markup 
> 
> <@s.form action="updatePerson">
>     <@s.textfield label="First name" name="firstName"
> extraParamName="blah"/>
>     <@s.submit value="Update"/>
> </...@s.form>
> 
> The JSP does not recognize this as a tag at all; all of the above is
> printed to HTML verbatim. Is there anything I need to do, namespace
> definition, etc. to make the engine understand that I use tags and not
> literals? I understand that FreeMarker tags are extensions that are
> shipped with default Struts distro, right?
> 
> Thank you very much
> 
> Greg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/

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


RE: FreeMarker Tags Help - setup

Posted by Martin Gainty <mg...@hotmail.com>.
Good Afternoon Greg

here is an example of forms using freemarker templates in chat\chatLogin.ftl
<html>
    <head>
        <title>Showcase - Chat - Login</title>
        <@s.head />
    </head>
    <body>
    <@s.actionerror />
    <@s.actionmessage />
    <@s.fielderror />
    <@s.form action="login" namespace="/chat" method="POST">
        <@s.textfield name="name" label="Name" required="true" />
        <@s.submit/>
    </...@s.form>
    </body>
</html>

//in order for the container to render this script one needs to define the FreemarkerPageFilter in web.xml
//here is mine (transcribed from showcase/WEB-INF/web.xml)

    <!-- SNIPPET START: example.freemarker.filter.chain
    <filter>
        <filter-name>struts-cleanup</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
    </filter>
    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>org.apache.struts2.sitemesh.FreeMarkerPageFilter</filter-class>
    </filter>
    <filter>
        <filter-name>struts</filter-name>
        <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts-cleanup</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    END SNIPPET: example.freemarker.filter.chain -->

//BTW my non-xhtml (simple theme) ftl files are located in
//struts2-showcase-2.1.6\WEB-INF\classes\template\simple

//my xhtml ftl files are located on 
//struts2-showcase-2.1.6\WEB-INF\classes\template\xhtml

//the location of this folder are resolved by 3 parameters defined in /org/apache/struts2/default.properties
### Standard UI theme
### Change this to reflect which path should be used for JSP control tag templates by default
struts.ui.theme=simple

####location of template dir
struts.ui.templateDir=template

#sets the default template type. Either ftl, vm, or jsp
struts.ui.templateSuffix=ftlthis is one solution and I am sure there other available solutions from the group monitoring this list

Does this help?
Martin Gainty 
______________________________________________ 
Disclaimer and Confidentiality Notice
Please be respectful of the rights of transmitter and recipient and do not alter/modify or obstruct this transmission. Thank You




> Subject: FreeMarker Tags Help - setup
> Date: Fri, 18 Sep 2009 13:09:31 -0400
> From: Greg.Slonim@usdoj.gov
> To: user@struts.apache.org
> 
> Hello,
> 
> Setup: struts2 (2.1.6) with Spring (2.5)
> 
> I Refer to the article in the docs 
> 
> http://struts.apache.org/2.1.6/docs/freemarker-tags.html
> 
> We are trying to use FreeMarker tags with a custom theme in order to
> pass extra parameters to the tag which the tag does not define (section
> of the above doc "Using inline attributes with templates")
> 
> When I attempt to use the markup 
> 
> <@s.form action="updatePerson">
>     <@s.textfield label="First name" name="firstName"
> extraParamName="blah"/>
>     <@s.submit value="Update"/>
> </...@s.form>
> 
> The JSP does not recognize this as a tag at all; all of the above is
> printed to HTML verbatim. Is there anything I need to do, namespace
> definition, etc. to make the engine understand that I use tags and not
> literals? I understand that FreeMarker tags are extensions that are
> shipped with default Struts distro, right?
> 
> Thank you very much
> 
> Greg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/171222986/direct/01/

RE: FreeMarker Tags Help - setup

Posted by Martin Gainty <mg...@hotmail.com>.
Greg

Matt is a intelligent resource (and quite friendly too) i would try to get ahold of Matt directly
matt@raibledesigns.com

feel free to pingback for any questions/comments

thanks,
Martin Gainty 
______________________________________________ 
Please do not alter/modify or disrupt this transmission. Thank You



> Subject: RE: FreeMarker Tags Help - setup
> Date: Tue, 22 Sep 2009 10:11:07 -0400
> From: Greg.Slonim@usdoj.gov
> To: user@struts.apache.org
> 
> MMM... no, the result is a jsp, not ftl. I suppose I cannot mix and
> match, can I now? i.e. use jsp page and <@ tags on it?
> 
> 
> On a separate note, I suppose my biggest problem is that I am using the
> "app-fuse'd" version of Struts upgraded to 2.1.6 and somewhere along the
> customization line that Matt did, the tags get lost. I am changing a
> subject a bit, but does anyone has a successful how-to to completely
> change Struts version in Appfuse? We did it, but still cannot use the
> new struts-prepare and struts-execute filters. 
> 
> Thank you
> Greg
> 
> 
> -----Original Message-----
> From: j alex [mailto:strutstwouser@gmail.com] 
> Sent: Monday, September 21, 2009 1:06 PM
> To: Struts Users Mailing List
> Subject: Re: FreeMarker Tags Help - setup
> 
> I assume you are using <result type="freemarker"
> >your-ftl-file.ftl</result>
> ..i had no problems passing an extra param to the tag and accessing it
> in
> the custom theme FTL
> 
> 
> On Fri, Sep 18, 2009 at 10:39 PM, Slonim, Greg (USAEO) <
> Greg.Slonim@usdoj.gov> wrote:
> 
> > Hello,
> >
> > Setup: struts2 (2.1.6) with Spring (2.5)
> >
> > I Refer to the article in the docs
> >
> > http://struts.apache.org/2.1.6/docs/freemarker-tags.html
> >
> > We are trying to use FreeMarker tags with a custom theme in order to
> > pass extra parameters to the tag which the tag does not define
> (section
> > of the above doc "Using inline attributes with templates")
> >
> > When I attempt to use the markup
> >
> > <@s.form action="updatePerson">
> >    <@s.textfield label="First name" name="firstName"
> > extraParamName="blah"/>
> >    <@s.submit value="Update"/>
> > </...@s.form>
> >
> > The JSP does not recognize this as a tag at all; all of the above is
> > printed to HTML verbatim. Is there anything I need to do, namespace
> > definition, etc. to make the engine understand that I use tags and not
> > literals? I understand that FreeMarker tags are extensions that are
> > shipped with default Struts distro, right?
> >
> > Thank you very much
> >
> > Greg
> >
> >
> > ---------------------------------------------------------------------
> > 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
> 

_________________________________________________________________
Bing brings you health info from trusted sources.
http://www.bing.com/search?q=pet+allergy&form=MHEINA&publ=WLHMTAG&crea=TXT_MHEINA_Health_Health_PetAllergy_1x1

RE: FreeMarker Tags Help - setup

Posted by "Slonim, Greg (USAEO)" <Gr...@usdoj.gov>.
MMM... no, the result is a jsp, not ftl. I suppose I cannot mix and
match, can I now? i.e. use jsp page and <@ tags on it?


On a separate note, I suppose my biggest problem is that I am using the
"app-fuse'd" version of Struts upgraded to 2.1.6 and somewhere along the
customization line that Matt did, the tags get lost. I am changing a
subject a bit, but does anyone has a successful how-to to completely
change Struts version in Appfuse? We did it, but still cannot use the
new struts-prepare and struts-execute filters. 

Thank you
Greg


-----Original Message-----
From: j alex [mailto:strutstwouser@gmail.com] 
Sent: Monday, September 21, 2009 1:06 PM
To: Struts Users Mailing List
Subject: Re: FreeMarker Tags Help - setup

I assume you are using <result type="freemarker"
>your-ftl-file.ftl</result>
..i had no problems passing an extra param to the tag and accessing it
in
the custom theme FTL


On Fri, Sep 18, 2009 at 10:39 PM, Slonim, Greg (USAEO) <
Greg.Slonim@usdoj.gov> wrote:

> Hello,
>
> Setup: struts2 (2.1.6) with Spring (2.5)
>
> I Refer to the article in the docs
>
> http://struts.apache.org/2.1.6/docs/freemarker-tags.html
>
> We are trying to use FreeMarker tags with a custom theme in order to
> pass extra parameters to the tag which the tag does not define
(section
> of the above doc "Using inline attributes with templates")
>
> When I attempt to use the markup
>
> <@s.form action="updatePerson">
>    <@s.textfield label="First name" name="firstName"
> extraParamName="blah"/>
>    <@s.submit value="Update"/>
> </...@s.form>
>
> The JSP does not recognize this as a tag at all; all of the above is
> printed to HTML verbatim. Is there anything I need to do, namespace
> definition, etc. to make the engine understand that I use tags and not
> literals? I understand that FreeMarker tags are extensions that are
> shipped with default Struts distro, right?
>
> Thank you very much
>
> Greg
>
>
> ---------------------------------------------------------------------
> 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: FreeMarker Tags Help - setup

Posted by j alex <st...@gmail.com>.
I assume you are using <result type="freemarker" >your-ftl-file.ftl</result>
..i had no problems passing an extra param to the tag and accessing it in
the custom theme FTL


On Fri, Sep 18, 2009 at 10:39 PM, Slonim, Greg (USAEO) <
Greg.Slonim@usdoj.gov> wrote:

> Hello,
>
> Setup: struts2 (2.1.6) with Spring (2.5)
>
> I Refer to the article in the docs
>
> http://struts.apache.org/2.1.6/docs/freemarker-tags.html
>
> We are trying to use FreeMarker tags with a custom theme in order to
> pass extra parameters to the tag which the tag does not define (section
> of the above doc "Using inline attributes with templates")
>
> When I attempt to use the markup
>
> <@s.form action="updatePerson">
>    <@s.textfield label="First name" name="firstName"
> extraParamName="blah"/>
>    <@s.submit value="Update"/>
> </...@s.form>
>
> The JSP does not recognize this as a tag at all; all of the above is
> printed to HTML verbatim. Is there anything I need to do, namespace
> definition, etc. to make the engine understand that I use tags and not
> literals? I understand that FreeMarker tags are extensions that are
> shipped with default Struts distro, right?
>
> Thank you very much
>
> Greg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>