You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by boB Rudis <bo...@rudis.net> on 2001/05/01 16:22:23 UTC
Velocity forum demo (blab) port to Struts
Greetings,
Coming from a straight JSP/Servlet environment, I've been "debating"
whether to start using Struts or Velocity (they seem to "compete") as a
foundation for true MVC+ development. I'm not keen on re-writing the wheel
and would rather spend the limited time I have on back-end foundational
coding contributing to one of these projects rather than creating
yet-another-framework.
As part of the evaluation exercise, I ported the Velocity "blab" forum
demo to Struts and (a) wanted to get some feedback on whether I've
successfully managed to incorporate the strengths of Struts to the fullest
extent, (b) offer it up for inclusion with the rest of the examples, and
(c) gauge whether or not it proves to be a useful comparison tool for
others in the midst of the same decision making process. I've also got
some questions, but they won't make much sense without pointing to code
examples.
The jar file (which can be extracted directly to a tomcat
"webapps" directory) is at http://www.rudis.net/strutsforum.jar
All comments are welcome. I'll toss out questions on specifics in another
post.
(If this should have gone to the struts-dev list, please let me know).
thx,
boB Rudis
bob@rudis.net
+----------------+
| "Mind the gap" |
+----------------+
Re: Velocity forum demo (blab) port to Struts
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
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/
Re: Velocity forum demo (blab) port to Struts
Posted by boB Rudis <bo...@rudis.net>.
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).
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.
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.
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.
> 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.
> 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).
thx again,
boB Rudis
bob@rudis.net
+----------------+
| "Mind the gap" |
+----------------+
Re: Velocity forum demo (blab) port to Struts
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
boB Rudis wrote:
>
> Greetings,
>
> Coming from a straight JSP/Servlet environment, I've been "debating"
> whether to start using Struts or Velocity (they seem to "compete") as a
> foundation for true MVC+ development. I'm not keen on re-writing the wheel
> and would rather spend the limited time I have on back-end foundational
> coding contributing to one of these projects rather than creating
> yet-another-framework.
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.
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 :)
>
> As part of the evaluation exercise, I ported the Velocity "blab" forum
> demo to Struts and (a) wanted to get some feedback on whether I've
> successfully managed to incorporate the strengths of Struts to the fullest
> extent, (b) offer it up for inclusion with the rest of the examples, and
> (c) gauge whether or not it proves to be a useful comparison tool for
> others in the midst of the same decision making process. I've also got
> some questions, but they won't make much sense without pointing to code
> examples.
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.
>
> +----------------+
> | "Mind the gap" |
> +----------------+
mind the gap indeed :)
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/