You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Biesbrock, Kevin" <Bi...@aoins.com> on 2011/04/15 17:13:47 UTC
Velocity Inclusion in JSP
There seem to be plenty of documents outlining how to include a jsp in a
velocity template, but not the other way around. I am having a
difficult time finding information on how to include a Velocity template
in a JSP. I recognized the s:component tag could work, but my templates
are not currently in my template (or "theme") folder and I feel like
they don't belong there because they are specific to my app, not the
chosen theme. I don't have enough time with the schedule of our
application to go back and convert all of the JSPs to Velocity
templates.
So one solution I thought of would be to create an action that returns
the Velocity result...but I don't really know how I feel about this
approach:
<action name="getTemplate_*">
<result type="velocity">/WEB-INF/myVelocityTemplates/{1}.vm</result>
</action>
I would appreciate any guidance on this.
d[-_-]b \m/
Beez
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Velocity Inclusion in JSP
Posted by "Biesbrock, Kevin" <Bi...@aoins.com>.
From: Dave Newton [mailto:davelnewton@gmail.com]
> Do the templates use the same models as the web layer?
Actually, it would have been good to note that the contact information
is hard-coded. So there is no need for a model. I literally just need
to include a block of html-/css-formatted text.
Beez
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Velocity Inclusion in JSP
Posted by Dave Newton <da...@gmail.com>.
On Fri, Apr 15, 2011 at 1:03 PM, Biesbrock, Kevin wrote:
> So I have a block of contact information that we would like to appear similarly whenever it's displayed. So on our home page, on a printable confirmation page, or in a generated email -- it should always appear the same. Yesterday I emailed this group about this a little bit (and forgot to mention the context in this email), titled: 'Reading .properties From Top-Level Package'. Eric Lents suggested:
>
>> E-mail and Velocity are like peanut butter and jelly.
>
> So I found documentation on how to compile a Velocity template in a java class but cannot find anything that would show my e.g. contact block on the homepage. So I thought *maybe* the best approach would be to use an s:action tag that returned a Velocity result of the template I requested.
>
> In terms of my email, I can use Velocity to generate the email with no problem -- and can even include, toward the bottom, the contact block.
>
> Does that help identify my use-case a little more clearly?
Yep.
Do the templates use the same models as the web layer? If so, seems
like direct rendering would be *much* more efficient.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Velocity Inclusion in JSP
Posted by Dave Newton <da...@gmail.com>.
Seems like a JSP-based custom tag would be the easiest, but I don't
actually know what your template requirements are, so it's tough to
say.
What's the use-case?
Dave
On Fri, Apr 15, 2011 at 11:13 AM, Biesbrock, Kevin
<Bi...@aoins.com> wrote:
> There seem to be plenty of documents outlining how to include a jsp in a
> velocity template, but not the other way around. I am having a
> difficult time finding information on how to include a Velocity template
> in a JSP. I recognized the s:component tag could work, but my templates
> are not currently in my template (or "theme") folder and I feel like
> they don't belong there because they are specific to my app, not the
> chosen theme. I don't have enough time with the schedule of our
> application to go back and convert all of the JSPs to Velocity
> templates.
>
> So one solution I thought of would be to create an action that returns
> the Velocity result...but I don't really know how I feel about this
> approach:
> <action name="getTemplate_*">
> <result type="velocity">/WEB-INF/myVelocityTemplates/{1}.vm</result>
> </action>
>
> I would appreciate any guidance on this.
>
> d[-_-]b \m/
> Beez
>
>
> ---------------------------------------------------------------------
> 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