You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Erich Meier <Er...@methodpark.de> on 2001/05/31 12:41:07 UTC
Has anyone combined Velocity and Struts?
Hi!
I am evaluating webapp frameworks for a project. For a couple of reasons,
I found Struts to be one of the best. One disadvantage is it's clumsy
logic tags feature to realize flow control within the pages. Additionally,
I want to have a template engine avail.
Velocity is exactly what I was searching for. Simple but powerful.
So my question is: is it possible to integrate both systems? Any success
stories?
TIA,
Erich
--
Dr. Erich Meier, Software Process Improvement
3Soft GmbH, method park, Wetterkreuz 19a, 91058 Erlangen, Germany
Tel. +49-9131-97206-316 mailto:Erich.Meier@methodpark.de
Fax. +49-9131-97206-200 http://www.methodpark.de/
Re: Context question: is it threadsafe?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Nick Bauman wrote:
>
> Forget about web/servlets for a moment. I'm using Velocity in a mail
> templating system. (try _that_ with JSP!) I have a very basic question:
>
> VelocityContext context = new VelocityContext();
>
> Is the VelocityContext object threadsafe? Or do I have to instantiate one
> for each call to the template I want?
It is not threadsafe. You can reuse them, but a VelocityContext should
only be running down through one template at a time. So if you have to,
pool them.
geir
>
> Thanks for any insights.
>
> --
> Nick Bauman
> Software Developer
> 3023 Lynn #22
> Minneapolis, MN
> 55416
> Mobile Phone: (612) 810-7406
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!
Context question: is it threadsafe?
Posted by Nick Bauman <ni...@cortexity.com>.
Forget about web/servlets for a moment. I'm using Velocity in a mail
templating system. (try _that_ with JSP!) I have a very basic question:
VelocityContext context = new VelocityContext();
Is the VelocityContext object threadsafe? Or do I have to instantiate one
for each call to the template I want?
Thanks for any insights.
--
Nick Bauman
Software Developer
3023 Lynn #22
Minneapolis, MN
55416
Mobile Phone: (612) 810-7406
Re: Has anyone combined Velocity and Struts?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Erich Meier wrote:
>
> "Geir Magnusson Jr." wrote:
> > You can find the complete code here in our nightly snapshot or CVS.
> > it's under
> >
> > /contrib/temporary/struts-velocity
> >
> > I haven't had time to go further with it, but would love to work on it
> > with someone interested - ask questions here (or privately as it may be
> > off topic if we get too detailed...)
>
> Thanks a lot for that starting point. After some struggling with different
> tomcat and JDK versions, I finally managed to get it running.
>
> Is there any way to feed the result generated by Velocity back in the
> Struts engine? I'd like to generate Struts pages (with taglibs and
> other stuff) via Velocity.
>
> Or is this a too broken design?
>
Hm. I have used Velocity as a filter stage in a kind of iterative
XSLT-based content engine, and from that have come to believe that
anything is possible.
Can you give a short example of what you are trying to do? (real
short...)
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!
Re: Has anyone combined Velocity and Struts?
Posted by Erich Meier <Er...@methodpark.de>.
"Geir Magnusson Jr." wrote:
> You can find the complete code here in our nightly snapshot or CVS.
> it's under
>
> /contrib/temporary/struts-velocity
>
> I haven't had time to go further with it, but would love to work on it
> with someone interested - ask questions here (or privately as it may be
> off topic if we get too detailed...)
Thanks a lot for that starting point. After some struggling with different
tomcat and JDK versions, I finally managed to get it running.
Is there any way to feed the result generated by Velocity back in the
Struts engine? I'd like to generate Struts pages (with taglibs and
other stuff) via Velocity.
Or is this a too broken design?
Thanks for your help,
Erich
--
Dr. Erich Meier, Software Process Improvement
3Soft GmbH, method park, Wetterkreuz 19a, 91058 Erlangen, Germany
Tel. +49-9131-97206-316 mailto:Erich.Meier@methodpark.de
Fax. +49-9131-97206-200 http://www.methodpark.de/
Re: Has anyone combined Velocity and Struts?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Erich Meier wrote:
>
> Hi!
>
> I am evaluating webapp frameworks for a project. For a couple of reasons,
> I found Struts to be one of the best. One disadvantage is it's clumsy
> logic tags feature to realize flow control within the pages. Additionally,
> I want to have a template engine avail.
>
> Velocity is exactly what I was searching for. Simple but powerful.
>
> So my question is: is it possible to integrate both systems? Any success
> stories?
Yes - not a 'success story', but I did a demonstration example a little
while ago, showing how it's simple to integrate into the struts
framework.
You can find the complete code here in our nightly snapshot or CVS.
it's under
/contrib/temporary/struts-velocity
I haven't had time to go further with it, but would love to work on it
with someone interested - ask questions here (or privately as it may be
off topic if we get too detailed...)
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."
velocity servlet base config
Posted by piero de salvia <pi...@yahoo.com>.
Hello everybody,
as I'm just starting with Velocity, I thought it would
be nice to have a doc file explaining the basic config
of a web app with Velocity.
As I understand it:
- the template dir goes under web-inf
- other resources (images, content etc) go under web
root
- no mapping of *.vm templates is necessary to the
controller servlet
- the whole site structure is flattened, and you
determine what resources to merge with your templates
only by the request parameters.
Meaning, no more:
www.mysite.com/mysection/mysubsection/mytemplate.vm
only:
www.mysite.com/myVelocityservletalias?template=mytemplate.vm§=mysection&subsect=mysubsection
Is that right? Isn't it against the custom of of using
dirs and subdirs for files? In the book JavaServer
Pages by Fields and Kolb, it is reccomended that URLs
be intuitive and mask tech details.
I think widespread use of Velocity will only happen if
people find this kind of topics included in the docs.
thanks to everybody
piergiorgio de salvia
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35
a year! http://personal.mail.yahoo.com/
Re: Has anyone combined Velocity and Struts?
Posted by Erich Meier <Er...@methodpark.de>.
SORRY FOLKS!
My mailer hit me very hard - this should have gone privately to the original
poster.
Sorry again,
Erich
Erich Meier wrote:
>
> Hallo!
>
> Vielen Dank fuer die Informationen - ich habe Geirs Loesung am Laufen,
> die ja recht aehnlich zu der Eurigen ist. Habt Ihr eigentlich mal probiert, ob
> sich der Velocity-Template-Output wieder in Struts reinfuettern laesst? Das
> wuerde es erlauben, die ganzen custom taglibs mitzubenutzen.
>
> Bei Geirs Loesung geht das naemlich nicht.
Re: Has anyone combined Velocity and Struts?
Posted by Erich Meier <Er...@methodpark.de>.
Hallo!
Vielen Dank fuer die Informationen - ich habe Geirs Loesung am Laufen,
die ja recht aehnlich zu der Eurigen ist. Habt Ihr eigentlich mal probiert, ob
sich der Velocity-Template-Output wieder in Struts reinfuettern laesst? Das
wuerde es erlauben, die ganzen custom taglibs mitzubenutzen.
Bei Geirs Loesung geht das naemlich nicht.
Gruss,
Erich
Thomas Fahrmeyer wrote:
>
> Yes. We are using it together very smoothly.
>
> Maybe it's working so easily because we are using a minimal functioniality
> from Struts. We are just using the flow control (struts-config.xml, Actions,
> ActionForms).
>
> We have an general presentation servlet which is derived from
> VelocityServlet and mapped to "view" in web.xml. So you can replace every
> call to a JSP page by this template and the requested template name.
>
> <action path="/doShowHausratComparisonDetails"
> type="ActionClass"
> scope="request"
> validate="true"
> >
> <forward name="success" path="/view/hausrat/detail01_hausrat.htm"/>
> </action>
>
> The JSP version would need:
> <forward name="success" path="/hausrat/detail01_hausrat.jsp"/>
>
> Additonal we have a framework for refilling the HTML Forms on errors. That's
> using Velocity too.
>
> Up to now we didn't think about adapting the other struts functionalities
> like MessageBean and so (I know Geir is much further ;)
Re: Has anyone combined Velocity and Struts?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Thomas Fahrmeyer wrote:
>
> Yes. We are using it together very smoothly.
Very cool!
>
> Maybe it's working so easily because we are using a minimal functioniality
> from Struts. We are just using the flow control (struts-config.xml, Actions,
> ActionForms).
>
> We have an general presentation servlet which is derived from
> VelocityServlet and mapped to "view" in web.xml. So you can replace every
> call to a JSP page by this template and the requested template name.
>
> <action path="/doShowHausratComparisonDetails"
> type="ActionClass"
> scope="request"
> validate="true"
> >
> <forward name="success" path="/view/hausrat/detail01_hausrat.htm"/>
> </action>
>
> The JSP version would need:
> <forward name="success" path="/hausrat/detail01_hausrat.jsp"/>
I did a similar thing - made a VelServlet and mapped *.vm requests to it
in web.xml.
> Additonal we have a framework for refilling the HTML Forms on errors. That's
> using Velocity too.
>
> Up to now we didn't think about adapting the other struts functionalities
> like MessageBean and so (I know Geir is much further ;)
>
You are generous in that assumption, but probably didn't look at my code
:)
No, it was a weekend hack that got the message bean working and such,
but that was to make it play nicely with the existing actions in the
struts-example. The idea was simply to see if I can get the
struts-example ported to use velocity rather than JSP with no changes to
the struts code or the action classes provided in the example. It needs
a good think-through to make sure the path I chose is sane. There is a
bit of a kludge to 'flatten' the three scopes into one context. For
complete interoperability, that might be a place to focus on...
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!
RE: Has anyone combined Velocity and Struts?
Posted by Thomas Fahrmeyer <th...@einsurance.de>.
Yes. We are using it together very smoothly.
Maybe it's working so easily because we are using a minimal functioniality
from Struts. We are just using the flow control (struts-config.xml, Actions,
ActionForms).
We have an general presentation servlet which is derived from
VelocityServlet and mapped to "view" in web.xml. So you can replace every
call to a JSP page by this template and the requested template name.
<action path="/doShowHausratComparisonDetails"
type="ActionClass"
scope="request"
validate="true"
>
<forward name="success" path="/view/hausrat/detail01_hausrat.htm"/>
</action>
The JSP version would need:
<forward name="success" path="/hausrat/detail01_hausrat.jsp"/>
Additonal we have a framework for refilling the HTML Forms on errors. That's
using Velocity too.
Up to now we didn't think about adapting the other struts functionalities
like MessageBean and so (I know Geir is much further ;)
Thomas
> -----Original Message-----
> From: Erich Meier [mailto:Erich.Meier@methodpark.de]
> Sent: Thursday, May 31, 2001 12:41 PM
> To: velocity-user@jakarta.apache.org
> Subject: Has anyone combined Velocity and Struts?
>
>
> Hi!
>
> I am evaluating webapp frameworks for a project. For a couple of reasons,
> I found Struts to be one of the best. One disadvantage is it's clumsy
> logic tags feature to realize flow control within the pages. Additionally,
> I want to have a template engine avail.
>
> Velocity is exactly what I was searching for. Simple but powerful.
>
> So my question is: is it possible to integrate both systems? Any success
> stories?
>
> TIA,
> Erich
> --
> Dr. Erich Meier, Software Process Improvement
> 3Soft GmbH, method park, Wetterkreuz 19a, 91058 Erlangen, Germany
> Tel. +49-9131-97206-316 mailto:Erich.Meier@methodpark.de
> Fax. +49-9131-97206-200 http://www.methodpark.de/