struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Velocity forum demo (blab) port to Struts
Date Tue, 01 May 2001 16:47:42 GMT
boB Rudis wrote:
> 
> Thx, geir (that was quick!)
> 
> > Struts and Velocity aren't comparable this way, because Velocity is
> > simply a template engine that can be used to provide the view layer for
> > a web app.  Struts is a framework that uses JSP for the view layer.
> >
> > I just want to make the distinction clear - I am not trying to
> > discourage (quite the contrary!), but the most approprate comparison
> > would be Struts and Turbine.
> 
> That makes an excellent starting point for my potential barrage of
> questions *:^) I dug through a good portion of the Velocity web site,
> including the "YMTD" document. I found the "poking" at Struts slightly
> humouous (which is where I got the notion of "competition"), but a bit in
> error, or at least deliberately misleading *:^). The YMTD doc seemed to
> indicate that taken on their own, one should choose between Struts and
> Velocity (in other places on the web site, it discussed the relationshp to
> Turbine).

That's good feedback.  That should be cleaned up.  I still believe that
they aren't comparable (even if people try...).  My motivation in doing
the struts-velocity example was to make it easier to compare JSP vs
Velocity w/o the framework issues getting in the way.  Turbine supports
JSP but most activity is with Velocity/WebMacro, and Struts is focused
on JSP, but you can do Velocity if you want to. 

> 
> So, I took a look at the forum demo (a fairly complete example) and
> noticed that the controller was trying to do a good portion of what Struts
> does "out of the box" (without the need to even write the
> controller). Even though I haven't decided the route to go yet, I got a
> bit defensive (in support of the Struts folks *:^) and ported it to
> Struts.

Well, remember, since Velocity is framework neutral, the demo had to
provide a controller servlet that would do the things otherwise handled
by a framework infrastructure.  I don't quite know if Velocity survived
your port :), but I would love to see it if so.  If you moved the form
demo to JSP, it's still interesting to me to see...

What would be fascinating would be :

1) A forum demo that used Struts and Velocity - would drop right into
Struts
2) A forum demo that used Turbine and Velocity - would drop right into
Turbine


> So my first question is, are Struts and Turbine competing
> projects? Apologies if this is answered in the Turbine site, but I didn't
> get to go through it yet.

I am not a part of the Struts or Turbine project, but in my personal
opinion, yes.  Both are frameworks that offer a set of services to build
web sites.

I can not speak about the relative merits of either, other than Turbine
supports both Velocity and JSP explicitly, and I believe that with a
little work, you could get implicit support of Velocity with all the
Struts trimmings.

> 
> Second: (not related to the first) - what would be the thoughts on
> extending the various struts-config.xml tags to have an attribute that can
> designate various forwards and actions as Velocity macros. Or,
> potentially extend it even further to make it more general? On the flip
> side, the Velocity API can be used to help support the
> "form-bean" concept.

That's not a question for me - I am not really part of the Struts
community - just an agent provocateur of sorts.  I would be interested
in helping work on that though.

I think that the Velocimacros offer great potential here - the problem
will be in how to specify the explicit arguments.  That's really all
theat the VMs offer over just forwarding to templates.    Velocity
offers a mechanism in the org.apache.velocity.app.Velocity class that
allows you to invoke the Velocimacros directly from code, so it's an
easy thing to do.

> 
> > You can use both Struts and Velocity, although there is no 'offical'
> > support for Velocity in Struts. I recently put together a little
> > demonstration package which can be found over in the Velocity CVS (under
> > contrib), but if you have already moved the forum demo, you probably
> > won't need to look at my cheesy example :)
> 
> Your example makes quite a bit of sense in terms of getting the various
> elements into the context so Velocity can use them. I'm thinking this can
> be done a bit more "under the covers" by the Struts framework itself,
> provided it had the necessary configuration info from the XML file.

Sure - the difference is that the Velocity context is at the simplest
use, flat, and the 'context' in Struts/JSP is three tiered - it was
solved via the context chaining, but as you can see, it was a bit kludgy
- the plan, if there was interest, was to extend with config XML,
analgous to how the bean mappings are performed, or similar.  I'd love
to hear your ideas.
 
> > I am willing to help you in any way you need.  If you want to give it a
> > home, we can put it in the velocity contrib CVS for now to make it easy
> > for others to access.
> 
> That would be great! Having it in available for comparison on both sides
> would potentially help others like me. I kinda need pointers on what
> license info needs to go where (Apache can have the example, especially
> since most of it is scraped from the Velocity forum demo *:^). I'll read
> up on the CVS docs at the web site.
> 
> One change I want to make is a conversion to using Struts templates (and I
> also need to fix an "error" in the <html:form> tags).

If I understand this, if you convert to JSP for the templates, where
would Velocity be involved?

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/

Mime
View raw message