You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Konstantin Priblouda <kp...@yahoo.com> on 2001/12/02 20:04:57 UTC
Struts/Velocity integration
Well, there was a lot of discussion about it.
What about to start doing something? :)
I played around today:
- Subclassed velocity servlet and added
"StrutsUtil" object to context.
- Implemented ( partially ) method message()
to get functionality like <bean:message> -
was really easy, most of code can be stolen
from RequestUtils, with zapping all jspish
stuff ( notably PageContext)
It worked perfectly ( and was easy )
anybody to join me?
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Go guys, go!
On 12/3/01 6:42 AM, "Gabriel Sidler" <si...@teamup.ch> wrote:
> Konstantin,
> I would be happy to work with you on this.
>
> Gabe
>
> Konstantin Priblouda wrote:
>>
>> Well, there was a lot of discussion about it.
>>
>> What about to start doing something? :)
>>
>> I played around today:
>>
>> - Subclassed velocity servlet and added
>> "StrutsUtil" object to context.
>>
>> - Implemented ( partially ) method message()
>> to get functionality like <bean:message> -
>> was really easy, most of code can be stolen
>> from RequestUtils, with zapping all jspish
>> stuff ( notably PageContext)
>>
>> It worked perfectly ( and was easy )
>>
>> anybody to join me?
>>
>> regards,
>>
>> =====
>> Konstantin Priblouda ( ko5tik ) Freelance Software developer
>> < http://www.pribluda.de > < play java games -> http://www.yook.de >
>> < render charts online -> http://www.pribluda.de/povray/ >
>>
>
> --
> Gabriel Sidler
> Software Engineer, Eivycom GmbH, Zurich, Switzerland
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 8:43 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
>> How about 'Velocity4Struts'?
> +1 :)
>
> Any objections anybody? :)
>
It's your project :)
However (there always is a 'however') how about
'VelocityForStruts'
(I think the 4 is cute, but in 'short' names, like log4j, dom4j, etc...)
vel4s?
:)
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> How about 'Velocity4Struts'?
+1 :)
Any objections anybody? :)
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Konstantin Priblouda wrote:
>
> --- Gabriel Sidler <si...@teamup.ch> wrote:
> > Our views are pretty much in line, it seems. Good!
> >
> > Konstantin Priblouda wrote:
> > [...]
> > > BTW, nothing prevents us from starting project on
> > > sourceforge - it's easiest way to get thing up and
> > > running.
> >
> > You are right. Are you going to initiate this?
>
> Yep. I will create project today and notify you.
>
> Any suggestion for name?
> ( most important for the moment :) )
How about 'Velocity4Struts'?
Gabe
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Rickard Öberg wrote:
>
> Konstantin Priblouda wrote:
>
> >>Alles klar! I was thinking about things like error
> >>messages, messages, URL formating, etc.
>
> You are talking about adapters that wraps the Struts stuff, right? Are
> are you doing a new framework?
>
No. The goal is to make the Struts stuff (error messages, internationalized
strings, etc.) available to a Velocity template designer.
Gabe
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Konstantin Priblouda wrote:
>>Alles klar! I was thinking about things like error
>>messages, messages, URL formating, etc.
You are talking about adapters that wraps the Struts stuff, right? Are
are you doing a new framework?
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
--- Gabriel Sidler <si...@teamup.ch> wrote:
> Our views are pretty much in line, it seems. Good!
>
> Konstantin Priblouda wrote:
> [...]
> > BTW, nothing prevents us from starting project on
> > sourceforge - it's easiest way to get thing up and
> > running.
>
> You are right. Are you going to initiate this?
Yep. I will create project today and notify you.
Any suggestion for name?
( most important for the moment :) )
> In case of doubt we leave it away from a first
> version.�
Yep. primary goal is to provide something really
usefull ( at least in our current
application contextes )
Generic stuff can come later...
> Alles klar! I was thinking about things like error
> messages, messages, URL formating, etc.
Yep. me too
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Our views are pretty much in line, it seems. Good!
Konstantin Priblouda wrote:
[...]
> BTW, nothing prevents us from starting project on
> sourceforge - it's easiest way to get thing up and
> running.
You are right. Are you going to initiate this?
> > - In Velocity: Provide equivalent alternatives to
> > the basic
> > JSP features (where meaningful). This might require
> > the development
> > of some context tools or Velocimacros.
>
> It's difficult decision, what's meaningfull :)
In case of doubt we leave it away from a first version.
> > - In Velocity: Provide equivalent alternatives to
> > the BEAN,
> > HTML, LOGIC and TEMPLATE tag libraries. I would
> > favor an approach
> > in phases. We need to look at the importance of the
> > tags and
> > define priorities. I am sure Ted will be able to
> > provide us
> > some useful input here. For example, the form tags
> > are a second
> > priority in my view.
>
> IMHO, logic and template tags are lowest priority [if
> any]. Velocity provides meaningfull alternatives ( in
> klartext: die können mir gestohlen bleiben :)
Alles klar! I was thinking about things like error
messages, messages, URL formating, etc.
[...]
> > - Documentation for the Velocity developer.
> very Important, but there is already velocity
> documentation.
Sure, I was thinking about doc as it relates to the Struts
integration.
[...]
> > - I favor very much an approach in short phases.
> > Let's get something
> > working soon and build on that in small steps.
>
> Me too. I already have some stuff ready, but I will
> be unable to hack on it until friday ( I'm sitting at
> the bank, and have merely access to my email :) )
No problem. I have a day job, too :-)
Gabe
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Mike Williams <mi...@cortexebusiness.com.au>.
>>> On Wed, 05 Dec 2001 08:15:26 +0100,
>>> "Rickard" == Rickard Öberg <ri...@xpedio.com> wrote:
Rickard> Where would template get its data from? $req/$res only? Using
Rickard> the #bean macro would allow them to "work on their own" fairly
Rickard> well though, in a Model-1 fashion.
Rickard> For WebWork there would have to be three parts of the story: the
Rickard> WW controller servlet which dishes out ValueStacks. Another
Rickard> servlet (coupled to .vm) then takes this and wraps the stacks
Rickard> into Velocity Contexts. The VelocityServlet would then be
Rickard> invoked which would render the template using the given
Rickard> Context. Thus, the WW servlet and the Velocity servlet would be
Rickard> agnostic of each other, and only the adapter servlet would know
Rickard> of both.
So are you talking about three distinct servlets? I don't know that it
needs to be that complicated, as you could have a utility object that
"wraps the stacks into Velocity Contexts" (or Maps). Something like this:
,--- people.vsp ---
| ## assume $request & $response are already in context
| #bean( "webwork.velocity.WebWorkUtil" $WebWork )
| #set( $root = $WebWork.getStack( $request ))
|
| <ul>
| #foreach ($person in $root.people)
| <li>$person.name</li>
| #end
| </ul>
This demonstrates that, rather than requiring the context to be primed
before the template is invoked, we simply use util objects to extract a
based on the standard $request/$response. The #bean() call above is
analogous to a JSP <%@ taglib %> declaration. And the servlet that handles
*.vsp doesn't need to know *anything* about WebWork.
--
cheers, Mike
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Mike Williams wrote:
> I love this thread! Mind if I chip in?
>
> I like the idea of a VelocityServlet that is independant of any control
> framework. Then, it becomes analagous to JSP, providing a common
> cross-framework presentation platform.
The only thing it'd need, at least from the WebWork framework
perspective, is the ability to suck in a pre-created context. This
context is created by the framework and put into the request somehow.
The servlet simply uses that as its context. Off the top of my head,
that would at least allow Velocity to be integrated into WebWork easily
Well it already is, through a custom VelocityServlet, but even more so.
> - VSPServlet should be usable in it's own right. You should be able to
> deploy it as-is (without subclassing) to handle *.vm or *.vsp files, and
> have it do something useful.
Where would template get its data from? $req/$res only? Using the #bean
macro would allow them to "work on their own" fairly well though, in a
Model-1 fashion.
> - Most of the time, you'd use it by having your control-framework attach
> some stuff to the request/session, and forward to a *.vm page. This is
> exactly analagous to JSP Model-2.
Ah, this answers the above. (Note to self: read first, then write.)
> - Integration with specific control-frameworks could be provided as helper
> objects and Velocimacros (analogous to Custom JSP tags). (These aren't
> part of the scope of VSPServlet, they're separate).
For WebWork there would have to be three parts of the story: the WW
controller servlet which dishes out ValueStacks. Another servlet
(coupled to .vm) then takes this and wraps the stacks into Velocity
Contexts. The VelocityServlet would then be invoked which would render
the template using the given Context. Thus, the WW servlet and the
Velocity servlet would be agnostic of each other, and only the adapter
servlet would know of both.
> - (I'm gonna regret this). If you were in a hurry, or seriously twisted,
> you could support something analogous to JSP Model-1, by having your *.vm
> load and use helper-objects to implement the control logic. Something
> like Rickard's #bean() macro would be useful as a factory for
> instantiating arbitrary objects from within the *.vm.
I fail to see why this would be twisted. Overall, I fail to see why
Model-1 is such a bad idea. AFAICT Model-2 is mostly useful when you
have switching logic to perform, i.e. when a process can lead to several
states. If you're just getting data and viewing it the states can only
be successful or system failure, the latter of which will cause the
whole thing to fail anyway. Thus, using a Model-1 approach there would
simplify things without removing any flexibility. It would make it
easier to follow as well, since for each Model-1 template you can see
directly in code what beans are being used. In a Model-2 scenario you
have to go look in some mapping file first, which is harder to do.
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
I just discovered yet another ground to put
JSP down the drain.
On every <jsp:include> it opens subrequest which
is not authenticated in any way -> I cannot
use my EJB which require valid authentication
( they cannot get authenticated user ID then )
So, if I use EJB from action class this request is
authenticated properly, but ater first include in JSP
it bombs....
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Mike,
your thoughts are in line with what I would like to achieve
through a Velocity/Struts integration.
We decided to keep this effort as a sub-project of Velocity
for now. We will use Source Forge for tool support. Konstantin
has applied for project space. It takes a few days to gain
access. I am sure he will announce it on this list when it's
ready. You are welcome to help.
Gabe
Mike Williams wrote:
>
> >>> "Gabriel" == Gabriel Sidler <si...@teamup.ch>
> >>> "Konstantin" == Konstantin Priblouda <kp...@yahoo.com>
>
> Konstantin> Agree. What we need is generally usable servlet, which can be
> Konstantin> easily adapted to whatever framework user like.
>
> I love this thread! Mind if I chip in?
>
> I like the idea of a VelocityServlet that is independant of any control
> framework. Then, it becomes analagous to JSP, providing a common
> cross-framework presentation platform.
>
> Er, for the purposes of this message, I'm gonna call it VSPServlet, to
> indicate that it's a kind of drop-in replacement for JSP. I'm sure there's
> a better name out there.
>
> Konstantin> VelocityServlet is nice example how to do this, but not very
> Konstantin> advanced.
>
> True, it could do with some enhancement, like adding the
> ServletResourceLoader that Geir has promised us :-)
>
> Just thinking aloud now ...
>
> - VSPServlet should be usable in it's own right. You should be able to
> deploy it as-is (without subclassing) to handle *.vm or *.vsp files, and
> have it do something useful.
>
> - Most of the time, you'd use it by having your control-framework attach
> some stuff to the request/session, and forward to a *.vm page. This is
> exactly analagous to JSP Model-2.
>
> - Integration with specific control-frameworks could be provided as helper
> objects and Velocimacros (analogous to Custom JSP tags). (These aren't
> part of the scope of VSPServlet, they're separate).
>
> - (I'm gonna regret this). If you were in a hurry, or seriously twisted,
> you could support something analogous to JSP Model-1, by having your *.vm
> load and use helper-objects to implement the control logic. Something
> like Rickard's #bean() macro would be useful as a factory for
> instantiating arbitrary objects from within the *.vm.
>
> Konstantin> BTW, nothing prevents us from starting project on sourceforge
> Konstantin> - it's easiest way to get thing up and running.
>
> IMHO, VSPServlet should stay as a sub-project of Velocity, as it would help
> prevent scope-creep. Any Struts integration, though, woudl be better off
> as a separate project.
>
> Gabriel> Support for Velocity templates as drop-in replacements for JSP
> Gabriel> templates. A Struts application can mix the use of JSP templates
> Gabriel> and Velocity templates.
>
> Ah, there you go, Gabriel has said all this already. Just ignore me.
>
> In any case, I'm keen to help.
>
> --
> cheers, Mike
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Mike Williams <mi...@cortexebusiness.com.au>.
>>> "Gabriel" == Gabriel Sidler <si...@teamup.ch>
>>> "Konstantin" == Konstantin Priblouda <kp...@yahoo.com>
Konstantin> Agree. What we need is generally usable servlet, which can be
Konstantin> easily adapted to whatever framework user like.
I love this thread! Mind if I chip in?
I like the idea of a VelocityServlet that is independant of any control
framework. Then, it becomes analagous to JSP, providing a common
cross-framework presentation platform.
Er, for the purposes of this message, I'm gonna call it VSPServlet, to
indicate that it's a kind of drop-in replacement for JSP. I'm sure there's
a better name out there.
Konstantin> VelocityServlet is nice example how to do this, but not very
Konstantin> advanced.
True, it could do with some enhancement, like adding the
ServletResourceLoader that Geir has promised us :-)
Just thinking aloud now ...
- VSPServlet should be usable in it's own right. You should be able to
deploy it as-is (without subclassing) to handle *.vm or *.vsp files, and
have it do something useful.
- Most of the time, you'd use it by having your control-framework attach
some stuff to the request/session, and forward to a *.vm page. This is
exactly analagous to JSP Model-2.
- Integration with specific control-frameworks could be provided as helper
objects and Velocimacros (analogous to Custom JSP tags). (These aren't
part of the scope of VSPServlet, they're separate).
- (I'm gonna regret this). If you were in a hurry, or seriously twisted,
you could support something analogous to JSP Model-1, by having your *.vm
load and use helper-objects to implement the control logic. Something
like Rickard's #bean() macro would be useful as a factory for
instantiating arbitrary objects from within the *.vm.
Konstantin> BTW, nothing prevents us from starting project on sourceforge
Konstantin> - it's easiest way to get thing up and running.
IMHO, VSPServlet should stay as a sub-project of Velocity, as it would help
prevent scope-creep. Any Struts integration, though, woudl be better off
as a separate project.
Gabriel> Support for Velocity templates as drop-in replacements for JSP
Gabriel> templates. A Struts application can mix the use of JSP templates
Gabriel> and Velocity templates.
Ah, there you go, Gabriel has said all this already. Just ignore me.
In any case, I'm keen to help.
--
cheers, Mike
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 8:20 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
>> I threw one of those together a while ago. I'll see
>> if I can dig it up.
>
> would be nice ...
>
>> Hang on for a sec. I am starting to detect 'scope
>> creep'.
>>
>> Doesn't Struts already have this stuff? Isn't the
>> point to make Velocity
>> easily available to Struts users? It's cool if we
>> can also add a bunch of
>> useful formatting/utility tools, but that's
>> secondary.
>>
>> Further, you would imagine that those tools are a
>> separate thing anyway -
>> Velocity will allow you to easily access *any* tool,
>> so why not just make
>> that effortless to share tools between JSP and Vel
>> in Struts, and let the
>> 'market' decide what tools it needs...
>
> agree. we will have to figure what parts of struts are
>
> necessary ( we will have to decide on priorities )
>
>
>> Hm. Don't you want to use the existing URL
>> formatting / action stuff that
>> is in struts, and not make new ones?
>
> Yes of course. But not necessary in the same form as
> in tag libraries.
Of course not :)
But the idea here is to integrat with struts (at least that's what the
Subject: of this thread leads me to believe.
Therefore, you would want it to be the case that you reuse the core
functionality in Struts, not mimic it. But I think we agree here.
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 10:33 AM, "Ted Husted" <hu...@apache.org> wrote:
> Looking over the original VelServlet example again, here's what jumps
> out at me:
>
>
> * We could use an ActionBean and ForwardBean to go along with the
> MessageBean, so
>
> <form name="logonForm" method="POST" action="logon.do">
>
> becomes
>
> <form name="logonForm" method="POST" action="$action.get('logon')">
>
> and
>
> <a href="editVelRegistration.do?action=Edit" ...>
>
> becomes
>
> <a href="$forward.get('editVelRegistration.do')" ...>
>
>
>
> * We probably also need a NameBean to return the magic constants the
> framework expects in some places.
>
> So
>
> <input type="submit" name="org.apache.struts.taglib.html.CANCEL"
>
> becomes
>
> <input type="submit" name="$name.getCancel()" ...
>
> and
>
> <input type="hidden" name="org.apache.struts.taglib.html.TOKEN"
> value="$sessionToken">
>
> becomes
>
> <input type="hidden" name="$name.getToken()" value="$sessionToken">
>
>
> I'm sure there ware other things, but does the basic pattern seem like a
> reasonable Velocity approach?
Yep.
>
> I believe its important that Struts be able to use Velocity on its own
> terms.
Definitely. That's the point here. Anything else is another framework
> Are there any other specific issues that people have with VelServlet?
>
> AFAIK, these are all API elements that VelServlet could generate itself,
> and work fine with Struts 1.0.
>
> Though, I agree that we can make this even easier for components to do
> in later releases.
Yep
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
Looking over the original VelServlet example again, here's what jumps
out at me:
* We could use an ActionBean and ForwardBean to go along with the
MessageBean, so
<form name="logonForm" method="POST" action="logon.do">
becomes
<form name="logonForm" method="POST" action="$action.get('logon')">
and
<a href="editVelRegistration.do?action=Edit" ...>
becomes
<a href="$forward.get('editVelRegistration.do')" ...>
* We probably also need a NameBean to return the magic constants the
framework expects in some places.
So
<input type="submit" name="org.apache.struts.taglib.html.CANCEL"
becomes
<input type="submit" name="$name.getCancel()" ...
and
<input type="hidden" name="org.apache.struts.taglib.html.TOKEN"
value="$sessionToken">
becomes
<input type="hidden" name="$name.getToken()" value="$sessionToken">
I'm sure there ware other things, but does the basic pattern seem like a
reasonable Velocity approach?
I believe its important that Struts be able to use Velocity on its own
terms.
Are there any other specific issues that people have with VelServlet?
AFAIK, these are all API elements that VelServlet could generate itself,
and work fine with Struts 1.0.
Though, I agree that we can make this even easier for components to do
in later releases.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
"Geir Magnusson Jr." wrote:
> > So, the plan would be for VelServlet to be a generic way to expose
> > Velocity to a framework that relies on the standard contexts. It would
> > have options for whether or not to chain the context with the request
> > and the session, what context name to use for the "getter", and a
> > factory method for inserting the getter into the Velocity context.
>
> Think that there shouldn't be either option as request and session should be
> in there for each and the key should be the same.
>
> This prevents portability problems as you can then always be guaranteed that
> you can mix templates from different apps.
Not getting what you are saying here. The request and session contexts
don't need keys. But there should be an option to represent them as
facade VelocityContexts, chained to the "real" Velocity Context. The
option would be set in the web.xml. If it is not set, then the facade's
don't happen, the designers only get what the developers send over in a
VelocityContext created in the Action.
So if the Action does this
request.setAttribute("itemForm",itemForm);
The template can just chant
$itemForm.getName
> The problem with this is that there are a huge number of application
> assumptions built into what you are calling 'VelServlet' that I don't
> believe should be in the Velocity core.
How about a a generalized version of what you started here
http://cvs.apache.org/viewcvs/jakarta-velocity/contrib/temporary/struts-velocity/src/java/org/apache/velocity/struts/
That didn't do any of the existing "look for Struts stuff", but that
optionally provided for the request/session facades, and did this:
public Object insertGetter(HttpServletRequest request) {
return null;
}
// ...
If (getterName!=null)
vel.put(getterName,insertGetter());
The getterName by default would be null, but could be set in the web.xml
The object would be the getter I mentioned, but the base VelServlet
would not specify any type of interface for that. It is simply
supporting the idea that a subclass may need to insert a getter object
to retrieve things from the application.
For the benefit of people attuned to the Velocity-way, I would also
suggest that it optionally support looking for a VelocityContext in the
request, under some name configured in the web.xml, and use that for the
base VelocityContext, when given.
So, depending on how the servlet is configured, it will or won't facade
the request/session, and a developer could pass it a ready-made
VelocityContext if they wanted to. A subclass could override
insertGetter and provide whatever delegate the application needed to
expose shared resources.
And then I can provide the Struts subclass of VelServlet in the Struts
CVS, which would include any and all assumptions about the getter's
interface.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 6:57 PM, "Ted Husted" <hu...@apache.org> wrote:
> "Geir Magnusson Jr." wrote:
>>> So, how about if we port the Veltag context gizmo to VelServlet, and
>>> provide a JavaBean that can return the Struts Action resources when
>>> given the current servlet request object.
>> Yep.
>
> If you can update the VelServlet with that then, I think I can handle
> the rest, and update the example application to use the amended "getter"
> syntax.
>
> So, the plan would be for VelServlet to be a generic way to expose
> Velocity to a framework that relies on the standard contexts. It would
> have options for whether or not to chain the context with the request
> and the session, what context name to use for the "getter", and a
> factory method for inserting the getter into the Velocity context.
Think that there shouldn't be either option as request and session should be
in there for each and the key should be the same.
This prevents portability problems as you can then always be guaranteed that
you can mix templates from different apps.
>
> It should also also watch for a VelocityContext being passed in the
> request, and then use that one instead of the blank one that VelServlet
> would otherwise provide. (The request key name for the VelocityContext
> being another servlet configuration.)
>
> I'll then subclass VelServlet to put a Struts resources getter into the
> Velocity context.
>
> A Velocity template can then get the Struts resources by chanting
> $getter, where, as far as Velocity is concerned, the getter is simply
> another JavaBean in the VelocityContext.
And don't worry about making it a bean. The interface can be as rich as you
want it to be...
> This should be enough to fulfill the Struts API contracts with the view,
> and the expectations of everyone concerned, without any changes to the
> Struts or Velocity cores .. proving once again that "Velocity is a
> full-featured templating tool, designed to work well in any Java
> application" .. even a Struts Web application ;-)
>
> If you can continue to host the generic VelServlet in the Velocity
> distribution, along with VelTag, then I will move toward hosting
> StrutsVelServlet in the Struts CVS.
The problem with this is that there are a huge number of application
assumptions built into what you are calling 'VelServlet' that I don't
believe should be in the Velocity core.
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
"Geir Magnusson Jr." wrote:
> > So, how about if we port the Veltag context gizmo to VelServlet, and
> > provide a JavaBean that can return the Struts Action resources when
> > given the current servlet request object.
> Yep.
If you can update the VelServlet with that then, I think I can handle
the rest, and update the example application to use the amended "getter"
syntax.
So, the plan would be for VelServlet to be a generic way to expose
Velocity to a framework that relies on the standard contexts. It would
have options for whether or not to chain the context with the request
and the session, what context name to use for the "getter", and a
factory method for inserting the getter into the Velocity context.
It should also also watch for a VelocityContext being passed in the
request, and then use that one instead of the blank one that VelServlet
would otherwise provide. (The request key name for the VelocityContext
being another servlet configuration.)
I'll then subclass VelServlet to put a Struts resources getter into the
Velocity context.
A Velocity template can then get the Struts resources by chanting
$getter, where, as far as Velocity is concerned, the getter is simply
another JavaBean in the VelocityContext.
This should be enough to fulfill the Struts API contracts with the view,
and the expectations of everyone concerned, without any changes to the
Struts or Velocity cores .. proving once again that "Velocity is a
full-featured templating tool, designed to work well in any Java
application" .. even a Struts Web application ;-)
If you can continue to host the generic VelServlet in the Velocity
distribution, along with VelTag, then I will move toward hosting
StrutsVelServlet in the Struts CVS.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 5:48 PM, "Ted Husted" <hu...@apache.org> wrote:
> "Geir Magnusson Jr." wrote:
>> In Veltag, there is a Context that does automatic scope searching for stuff,
>> so that might be of some help.
>> But how do we nicely integrate with the struts message bean?
>
> So, how about if we port the Veltag context gizmo to VelServlet, and
> provide a JavaBean that can return the Struts Action resources when
> given the current servlet request object.
Yep.
>
> public interface ActionResources {
>
> public void setResourceRequest(HttpServletRequest request);
>
> public DataSource getDataSource();
> public ActionErrors getActionErrors();
> public Throwable getException();
> public ActionFormBeans getActionFormBeans();
> public ActionForwards getActionForwards();
> public Locale getLocale();
> public ActionMappings getActionMappings();
> public MessageResources getMessageResouces();
> public DiskMultipartRequestHandler getMultipartHandler();
> public ActionServlet getActionServlet();
> public Servlet getServlet();
> public String getToken();
>
> public ActionForm getActionForm(String name);
> public ActionForward getActionForward(String name);
> public ActionMapping getActionMapping(String name);
>
> public ActionMapping getCurrentMapping();
> public ActionForm getCurrentActionForm();
>
> }
>
Looks good. Of course, with an interface you have problems as this grows -
how about a base impl? (Don¹t feel strongly either way, but if we key
things off an 'ActionResources' then anyone who makes a custom one gets
broken when the interface changes.)
> I think Donnie Hale is already working on something along these lines.
>
> And -- what if we turned the syntax from my last message around, so
> instead of
>
> $message.get('name');
>
> we had
>
> $get.message('name');
> $get.link('name');
> $get.name('name');
> $get.action('path');
> $get.tokenName();
> $get.tokenValue();
>
> Of course, "get" could be any identifier, I just chose something short
> and obvious. I'm also avoiding calling it Struts, because I don't think
> these resources are really "Struts" ideas, but "MVC" ideas that other
> frameworks might implement too.
+1
> The "getter" could then be a Velocity interface with a Struts
> implementation.
>
> In the ActionVelServlet (subclassed from VelServlet), the getter would
> be a wrapper, or delegate, around the ActionResources. So we'd
> instantiate the ActionResources with the request, and then pass that to
> a "getter", and put that into the VelocityContext.
>
> ActionResources actionResources = new ActionResourcesBase(request);
>
> VelocityGetter getter = new ActionGetter(actionResources);
>
> velocityContext.putAttribute('get',getter);
vc.put( "get", getter );
> The implementation of the ActionGetter would do simple but ugly things
> like
>
> public String message(String key) {
>
> return
> resources.getMessageResources().getMessage(resources.getLocale(),key);
>
> }
>
>
> And, I think that would finish what Geir started ;-)
>
Actually does it quite neatly, actually...
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Donnie Hale <do...@haleonline.net>.
I am working on that kind of interface for Struts. Since part of it is
refactoring ActionServlet (step-wise, but refactoring nonetheless), if &
when this shows up in Struts is TBD. For the time being, someone could
implement that interface for the Velocity side of the world more immediately
so at least the API is essentially correct (and hopefully final :).
Donnie
-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Wednesday, December 05, 2001 5:49 PM
To: Velocity Users List
Subject: Re: Struts/Velocity integration
"Geir Magnusson Jr." wrote:
> In Veltag, there is a Context that does automatic scope searching for
stuff,
> so that might be of some help.
> But how do we nicely integrate with the struts message bean?
So, how about if we port the Veltag context gizmo to VelServlet, and
provide a JavaBean that can return the Struts Action resources when
given the current servlet request object.
public interface ActionResources {
public void setResourceRequest(HttpServletRequest request);
public DataSource getDataSource();
public ActionErrors getActionErrors();
public Throwable getException();
public ActionFormBeans getActionFormBeans();
public ActionForwards getActionForwards();
public Locale getLocale();
public ActionMappings getActionMappings();
public MessageResources getMessageResouces();
public DiskMultipartRequestHandler getMultipartHandler();
public ActionServlet getActionServlet();
public Servlet getServlet();
public String getToken();
public ActionForm getActionForm(String name);
public ActionForward getActionForward(String name);
public ActionMapping getActionMapping(String name);
public ActionMapping getCurrentMapping();
public ActionForm getCurrentActionForm();
}
I think Donnie Hale is already working on something along these lines.
And -- what if we turned the syntax from my last message around, so
instead of
$message.get('name');
we had
$get.message('name');
$get.link('name');
$get.name('name');
$get.action('path');
$get.tokenName();
$get.tokenValue();
Of course, "get" could be any identifier, I just chose something short
and obvious. I'm also avoiding calling it Struts, because I don't think
these resources are really "Struts" ideas, but "MVC" ideas that other
frameworks might implement too.
The "getter" could then be a Velocity interface with a Struts
implementation.
In the ActionVelServlet (subclassed from VelServlet), the getter would
be a wrapper, or delegate, around the ActionResources. So we'd
instantiate the ActionResources with the request, and then pass that to
a "getter", and put that into the VelocityContext.
ActionResources actionResources = new ActionResourcesBase(request);
VelocityGetter getter = new ActionGetter(actionResources);
velocityContext.putAttribute('get',getter);
The implementation of the ActionGetter would do simple but ugly things
like
public String message(String key) {
return
resources.getMessageResources().getMessage(resources.getLocale(),key);
}
And, I think that would finish what Geir started ;-)
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
"Geir Magnusson Jr." wrote:
> In Veltag, there is a Context that does automatic scope searching for stuff,
> so that might be of some help.
> But how do we nicely integrate with the struts message bean?
So, how about if we port the Veltag context gizmo to VelServlet, and
provide a JavaBean that can return the Struts Action resources when
given the current servlet request object.
public interface ActionResources {
public void setResourceRequest(HttpServletRequest request);
public DataSource getDataSource();
public ActionErrors getActionErrors();
public Throwable getException();
public ActionFormBeans getActionFormBeans();
public ActionForwards getActionForwards();
public Locale getLocale();
public ActionMappings getActionMappings();
public MessageResources getMessageResouces();
public DiskMultipartRequestHandler getMultipartHandler();
public ActionServlet getActionServlet();
public Servlet getServlet();
public String getToken();
public ActionForm getActionForm(String name);
public ActionForward getActionForward(String name);
public ActionMapping getActionMapping(String name);
public ActionMapping getCurrentMapping();
public ActionForm getCurrentActionForm();
}
I think Donnie Hale is already working on something along these lines.
And -- what if we turned the syntax from my last message around, so
instead of
$message.get('name');
we had
$get.message('name');
$get.link('name');
$get.name('name');
$get.action('path');
$get.tokenName();
$get.tokenValue();
Of course, "get" could be any identifier, I just chose something short
and obvious. I'm also avoiding calling it Struts, because I don't think
these resources are really "Struts" ideas, but "MVC" ideas that other
frameworks might implement too.
The "getter" could then be a Velocity interface with a Struts
implementation.
In the ActionVelServlet (subclassed from VelServlet), the getter would
be a wrapper, or delegate, around the ActionResources. So we'd
instantiate the ActionResources with the request, and then pass that to
a "getter", and put that into the VelocityContext.
ActionResources actionResources = new ActionResourcesBase(request);
VelocityGetter getter = new ActionGetter(actionResources);
velocityContext.putAttribute('get',getter);
The implementation of the ActionGetter would do simple but ugly things
like
public String message(String key) {
return
resources.getMessageResources().getMessage(resources.getLocale(),key);
}
And, I think that would finish what Geir started ;-)
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Ted Husted wrote:
>
> Gabriel Sidler wrote:
> > I will put something working together based on these ideas/code
> > this coming weekend (I am tied up with my projects today/tomorrow).
> > I hope this will simplify further discussions.
>
> That sounds great, Gabe.
>
> If someone could provide something like VelServlet
>
> <
> http://cvs.apache.org/viewcvs/jakarta-velocity/contrib/temporary/struts-velocity/src/java/org/apache/velocity/struts/
> >
>
> that just
>
> + Creates an empty VelocityContext or uses one passed in the request,
> under a key specified in the web.xml
>
> + Optionally chains the request and session contexts as facade
> VelocityContexts
>
> + Does something like this:
>
> public Object insertGetter(HttpServletRequest request) {
> return null;
> }
>
> // ...
>
> If (getterName!=null)
> vel.put(getterName,insertGetter());
>
> I could subclass that and add a "getter" that exposed the Struts
> resources. We could then work on updating the Struts examples, and maybe
> some other examples, to show how the getter is used to fulfill the
> Struts API contracts with a presentation page.
I get the idea. I think I can provide you this without too much
effort. I have a few questions regarding the proposed approach
but will hold back for now until we have something working. That'll
make it easier to discuss.
>
> I believe that this would provide a simple, seamless environment that
> can be configured to "toe the Velocity line", or to work as a drop-in
> replacement for a Struts JSP (no changes to Action class source code,
> just change something.jsp to something.vm in the Struts configuration
> file and reload).
>
> This makes it easy for a Struts team to take Velocity for a spin, and
> even run some apples:apples benchmarks.
>
Yes! I'am looking forward to it.
Gabe
> At the same time, it makes Velocity+Struts a viable option for Velocity
> teams who prefer the VelocityContext and shun the request and session
> contexts.
>
> Best yet, it provides a clear migration path for teams that are in one
> place and want to get to the other, but can't do it overnight.
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
> Konstantin Priblouda wrote:
> >
> > --- Ted Husted <hu...@apache.org> wrote:
> > > Gabriel Sidler wrote:
> > > > I will put something working together based on
> > > these ideas/code
> > > > this coming weekend (I am tied up with my projects
> > > today/tomorrow).
> > > > I hope this will simplify further discussions.
> > >
> > > That sounds great, Gabe.
> >
> > I can hack on it tomorrow & over weekend . And can
> > share my code with Gabriel ( if he likes :) )
Hallo Konstantin,
How is it going? Anywhere I can jump in?
Gabe
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Konstantin Priblouda wrote:
>
> --- Ted Husted <hu...@apache.org> wrote:
> > Gabriel Sidler wrote:
> > > I will put something working together based on
> > these ideas/code
> > > this coming weekend (I am tied up with my projects
> > today/tomorrow).
> > > I hope this will simplify further discussions.
> >
> > That sounds great, Gabe.
>
> I can hack on it tomorrow & over weekend . And can
> share my code with Gabriel ( if he likes :) )
Sure!
Gabe
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Send your FREE holiday greetings online!
> http://greetings.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
--- Ted Husted <hu...@apache.org> wrote:
> Gabriel Sidler wrote:
> > I will put something working together based on
> these ideas/code
> > this coming weekend (I am tied up with my projects
> today/tomorrow).
> > I hope this will simplify further discussions.
>
> That sounds great, Gabe.
I can hack on it tomorrow & over weekend . And can
share my code with Gabriel ( if he likes :) )
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
Gabriel Sidler wrote:
> I will put something working together based on these ideas/code
> this coming weekend (I am tied up with my projects today/tomorrow).
> I hope this will simplify further discussions.
That sounds great, Gabe.
If someone could provide something like VelServlet
<
http://cvs.apache.org/viewcvs/jakarta-velocity/contrib/temporary/struts-velocity/src/java/org/apache/velocity/struts/
>
that just
+ Creates an empty VelocityContext or uses one passed in the request,
under a key specified in the web.xml
+ Optionally chains the request and session contexts as facade
VelocityContexts
+ Does something like this:
public Object insertGetter(HttpServletRequest request) {
return null;
}
// ...
If (getterName!=null)
vel.put(getterName,insertGetter());
I could subclass that and add a "getter" that exposed the Struts
resources. We could then work on updating the Struts examples, and maybe
some other examples, to show how the getter is used to fulfill the
Struts API contracts with a presentation page.
I believe that this would provide a simple, seamless environment that
can be configured to "toe the Velocity line", or to work as a drop-in
replacement for a Struts JSP (no changes to Action class source code,
just change something.jsp to something.vm in the Struts configuration
file and reload).
This makes it easy for a Struts team to take Velocity for a spin, and
even run some apples:apples benchmarks.
At the same time, it makes Velocity+Struts a viable option for Velocity
teams who prefer the VelocityContext and shun the request and session
contexts.
Best yet, it provides a clear migration path for teams that are in one
place and want to get to the other, but can't do it overnight.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
"Geir Magnusson Jr." wrote:
[...]
> Sure, and it's really straightforward. The worrisome part is the connection
> to 'struts stuff', which will make it worthwhile.
>
> I wonder if we should choose a target, say the messages and see what
> happens? In the proof-of-concept thing I threw together, there is a
> 'VelServlet' that does what you want or is a start. You can just map .vm
> requests to it.
>
> In Veltag, there is a Context that does automatic scope searching for stuff,
> so that might be of some help.
Yes, that's exactly one of the missing pieces of the puzzle.
Things are coming together nicely.
> But how do we nicely integrate with the struts message bean?
Ted's proposed approach with an ActionResources class along with
a Getter class seems like a resonable approach.
I will put something working together based on these ideas/code
this coming weekend (I am tied up with my projects today/tomorrow).
I hope this will simplify further discussions.
Gabe
>
> That might be a good first step.
>
> --
> Geir Magnusson Jr. geirm@optonline.net
> System and Software Consulting
> "Whoever would overthrow the liberty of a nation must begin by subduing the
> freeness of speech." - Benjamin Franklin
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Tim Colson <tc...@cisco.com>.
Geir wrote:
> The worrisome part is the connection to 'struts stuff',
> which will make it worthwhile.
> But how do we nicely integrate with the struts message bean?
Won't the API glue that Ted was suggesting for the Struts project do the
trick?
StrutsAPI.getMessages() -> which does the following under the covers:
return (MessageResources) context.getAttribute( Action.MESSAGES_KEY );
In the Struts 1.0 timeframe, VelServlet just needs enough brains to know
what to pull out of the request/session/app, to wrap and throw into the
VelContext.
Which uh, it does already, right?
Am I oversimplifying?
Tim
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 8:51 AM, "Gabriel Sidler" <si...@teamup.ch> wrote:
> "Geir Magnusson Jr." wrote:
>>
>> On 12/5/01 7:07 AM, "Gabriel Sidler" <si...@teamup.ch> wrote:
>>
>>> "Geir Magnusson Jr." wrote:
>>> [...]
>>>>> I keep thinking that a base VelocityServlet seems like a perfectly valid
>>>>> feature to me, and wouldn't need ties to Struts or any other framework.
>>>>> Just open the door to acting as an independant servlet service that
>>>>> chained the standard servlet contexts behind a regular VelocityContext.
>>>>
>>>> Except that such a beastie can't stand on it's own. Unlike a JSP, the
>>>> velocity template has to be fed... Something has to be put into the
>>>> context....
>>>
>>> Yes, the standard servlet contexts request, session and application.
>>> It should be perfectly possible to write a simple application this way.
>>>
>>> In this regard I don't see any conceptual differences between JSP
>>> and Velocity. Do I miss something?
>>>
>>
>> How would you go fetch data from a database?
>
> That would be difficult :-). No question, for such an application the
> use of a framework makes sense.
>
> I was more thinking of simple apps like:
> - Dynamic inclusion of footer, header, menus
> - Dynamic menus
> - Support simple customization using information stored in cookies,
> for example remember the language choosen on your last visit
> - Dynamically build URLs
> - Customize the HTML code based on browser type, host name, port,
> protocol, etc. etc.
I don't think I've ever done that. I always need to get to a DB :) I think
that your market would be quite small w/o data access.
> All I am saying is that a standalone VelocityServlet is able to live
> and do a few useful things. It would do all I need for my home page :-)
Right - and it would be useful. However, you still need the Model2 pattern
of a controller... and Struts provides that...
> I liked Ted's idea to start which such a simple VelocityServlet as the
> basis for the integration work. Then, subclass it to add the specific
> features needed for interaction with Struts. This would then be the
> StrutsVelocityServlet, so to speak. Does this make any sense?
Sure, and it's really straightforward. The worrisome part is the connection
to 'struts stuff', which will make it worthwhile.
I wonder if we should choose a target, say the messages and see what
happens? In the proof-of-concept thing I threw together, there is a
'VelServlet' that does what you want or is a start. You can just map .vm
requests to it.
In Veltag, there is a Context that does automatic scope searching for stuff,
so that might be of some help.
But how do we nicely integrate with the struts message bean?
That might be a good first step.
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
"Geir Magnusson Jr." wrote:
>
> On 12/5/01 7:07 AM, "Gabriel Sidler" <si...@teamup.ch> wrote:
>
> > "Geir Magnusson Jr." wrote:
> > [...]
> >>> I keep thinking that a base VelocityServlet seems like a perfectly valid
> >>> feature to me, and wouldn't need ties to Struts or any other framework.
> >>> Just open the door to acting as an independant servlet service that
> >>> chained the standard servlet contexts behind a regular VelocityContext.
> >>
> >> Except that such a beastie can't stand on it's own. Unlike a JSP, the
> >> velocity template has to be fed... Something has to be put into the
> >> context....
> >
> > Yes, the standard servlet contexts request, session and application.
> > It should be perfectly possible to write a simple application this way.
> >
> > In this regard I don't see any conceptual differences between JSP
> > and Velocity. Do I miss something?
> >
>
> How would you go fetch data from a database?
That would be difficult :-). No question, for such an application the
use of a framework makes sense.
I was more thinking of simple apps like:
- Dynamic inclusion of footer, header, menus
- Dynamic menus
- Support simple customization using information stored in cookies,
for example remember the language choosen on your last visit
- Dynamically build URLs
- Customize the HTML code based on browser type, host name, port,
protocol, etc. etc.
All I am saying is that a standalone VelocityServlet is able to live
and do a few useful things. It would do all I need for my home page :-)
I liked Ted's idea to start which such a simple VelocityServlet as the
basis for the integration work. Then, subclass it to add the specific
features needed for interaction with Struts. This would then be the
StrutsVelocityServlet, so to speak. Does this make any sense?
Gabe
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 6:07 PM, "Mike Williams" <mi...@cortexebusiness.com.au> wrote:
> Geir> How would you go fetch data from a database?
>
> Mike> Answer #1 - you wouldn't. You'd expect all the "model" data to be
> attached
> Mike> to the $request before the template in invoked.
>
> Mike> Answer #2 - you'd attach a Util object (that knew how to do the database
> Mike> access) as a request attribute, thus making it available to the
> template.
>
> Geir> HOW?
>
> Geir> It's a bootstrap problem. As I understood what I was replying to,
> Geir> the suggestion was a servlet that is a direct analogue for the
> Geir> JspServlet - i.e. It 'renders' a JSP.
>
> Yup.
>
> Geir> request comes in to the servlet engine, gets mapped to the
> Geir> VelServlet, and then VelServlet might put the session into the
> Geir> context (so you can get at the scopes) and then render the
> Geir> requested template. Where in that sequence do you attach model
> Geir> data to the request (answer 1) or attach the util object (answer 2)
> Geir> ??
>
> Well, it's just like JSP Model-2: there's a controller framework that
> handles requests before they're passed to VelServlet.
Yes. I understand this. This was my point - it cant' stand alone... It
needs a controller somewhere...
The post/thread I was replying to seemed to be suggesting that a VelServlet
was enough.
It's necessary, but not sufficient for struts integration...
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Mike Williams <mi...@cortexebusiness.com.au>.
Geir> How would you go fetch data from a database?
Mike> Answer #1 - you wouldn't. You'd expect all the "model" data to be attached
Mike> to the $request before the template in invoked.
Mike> Answer #2 - you'd attach a Util object (that knew how to do the database
Mike> access) as a request attribute, thus making it available to the template.
Geir> HOW?
Geir> It's a bootstrap problem. As I understood what I was replying to,
Geir> the suggestion was a servlet that is a direct analogue for the
Geir> JspServlet - i.e. It 'renders' a JSP.
Yup.
Geir> request comes in to the servlet engine, gets mapped to the
Geir> VelServlet, and then VelServlet might put the session into the
Geir> context (so you can get at the scopes) and then render the
Geir> requested template. Where in that sequence do you attach model
Geir> data to the request (answer 1) or attach the util object (answer 2)
Geir> ??
Well, it's just like JSP Model-2: there's a controller framework that
handles requests before they're passed to VelServlet. The browser doesn't
request a *.vsp page, they request that some action be performed. For e.g.
- Browser submits a request to "editNote.do"
- Struts directs control to EditNoteAction
- EditNoteAction retrieves the note, and attaches (some representation
of) it to the request
- Struts forwards control to "noteDetails.vsp"
- VelServlet creates a context, populates it with $request (or some
wrapper), and renders "noteDetails.vsp"
- "noteDetails.vsp" extracts the note object from the $request
How does that sound? Am I being particularly thick?
Answer #2 is similar, except that "noteDetails.vsp" extracts an
helper-object that knows how to GET the note object from the $request,
rather than the note itself.
Having said that, it would be possible (though not advisable) to bootstrap
the whole thing from the *.vsp page:
#set( $NoteHelper = $BeanFactory.makeBean( "some.NoteHelper" ))
#set( $note = $NoteHelper.getNote( $request ))
## ... etc etc ...
--
cheers, Mike
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 5:36 PM, "Mike Williams" <mi...@cortexebusiness.com.au> wrote:
> Gabriel> Yes, the standard servlet contexts request, session and application.
> Gabriel> It should be perfectly possible to write a simple application this
> way.
>
> Gabriel> In this regard I don't see any conceptual differences between JSP
> Gabriel> and Velocity. Do I miss something?
>
> Geir> How would you go fetch data from a database?
>
> Answer #1 - you wouldn't. You'd expect all the "model" data to be attached
> to the $request before the template in invoked.
>
> Answer #2 - you'd attach a Util object (that knew how to do the database
> access) as a request attribute, thus making it available to the template.
HOW?
It's a bootstrap problem. As I understood what I was replying to, the
suggestion was a servlet that is a direct analogue for the JspServlet - i.e.
It 'renders' a JSP.
So if we had that (and there is one in the struts POC example in contrib)
then a request comes in to the servlet engine, gets mapped to the
VelServlet, and then VelServlet might put the session into the context (so
you can get at the scopes) and then render the requested template.
Where in that sequence do you attach model data to the request (answer 1) or
attach the util object (answer 2) ??
See?
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Mike Williams <mi...@cortexebusiness.com.au>.
Gabriel> Yes, the standard servlet contexts request, session and application.
Gabriel> It should be perfectly possible to write a simple application this way.
Gabriel> In this regard I don't see any conceptual differences between JSP
Gabriel> and Velocity. Do I miss something?
Geir> How would you go fetch data from a database?
Answer #1 - you wouldn't. You'd expect all the "model" data to be attached
to the $request before the template in invoked.
Answer #2 - you'd attach a Util object (that knew how to do the database
access) as a request attribute, thus making it available to the template.
--
cheers, Mike
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 7:07 AM, "Gabriel Sidler" <si...@teamup.ch> wrote:
> "Geir Magnusson Jr." wrote:
> [...]
>>> I keep thinking that a base VelocityServlet seems like a perfectly valid
>>> feature to me, and wouldn't need ties to Struts or any other framework.
>>> Just open the door to acting as an independant servlet service that
>>> chained the standard servlet contexts behind a regular VelocityContext.
>>
>> Except that such a beastie can't stand on it's own. Unlike a JSP, the
>> velocity template has to be fed... Something has to be put into the
>> context....
>
> Yes, the standard servlet contexts request, session and application.
> It should be perfectly possible to write a simple application this way.
>
> In this regard I don't see any conceptual differences between JSP
> and Velocity. Do I miss something?
>
How would you go fetch data from a database?
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Be a giant. Take giant steps. Do giant things...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Konstantin Priblouda wrote:
> You can take login name out of session, but to get
> to his real name you need some interaction with
> backend. So, there has to be bean in context
> which holds this name.
>
> How do you get it?
>
> Of course, you can instantiate beans through macros,
> but it's "not convenient"
I fail to see why.
> I would fawor following solution:
> define "context populators" which are implicitely
> mapped to templates. Maybe with some kind of
> "default behaviour" ( look at Html::Mason dhandlers
> - though it's perl, but nevertheless nice tool )
Isn't this exactly what Struts and WebWork and other frameworks already do?
> Say, if somebody calls template
> "/foo/bar/blurge/bang.vm" execute following
> populators:
>
> ContextPopulator
> foo.ContextPopulator
> foo.bar.ContextPopulator
> foo.bar.blurge.ContextPopulator
> foo.bar.blurge.BangPopulator
>
> if they are existing.
This will be utterly and completely confusing IMHO. But you do what you
will do ;-)
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 7:29 AM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> On 12/5/01 7:13 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
>>
>> --- Gabriel Sidler <si...@teamup.ch> wrote:
>>> "Geir Magnusson Jr." wrote:
>>> [...]
>>>>> I keep thinking that a base VelocityServlet
>>> seems like a perfectly valid
>>>>> feature to me, and wouldn't need ties to Struts
>>> or any other framework.
>>>>> Just open the door to acting as an independant
>>> servlet service that
>>>>> chained the standard servlet contexts behind a
>>> regular VelocityContext.
>>>>
>>>> Except that such a beastie can't stand on it's
>>> own. Unlike a JSP, the
>>>> velocity template has to be fed... Something has
>>> to be put into the
>>>> context....
>>>
>>> Yes, the standard servlet contexts request, session
>>> and application.
>>> It should be perfectly possible to write a simple
>>> application this way.
>>>
>>> In this regard I don't see any conceptual
>>> differences between JSP
>>> and Velocity. Do I miss something?
>>
>> Yes. You miss something.
>>
>> In JSP you can make scriptlet somewhere near start,
>> where you pull all your data from some kind of
>> backend - in Velocity you need to initialize and put
>> some beans in context.
>>
>> Say, in protected area you lite to display "hello
>> foobar" where foobar is logged in user name
>> ( but not his login name )
>>
>> You can take login name out of session, but to get
>> to his real name you need some interaction with
>> backend. So, there has to be bean in context
>> which holds this name.
>>
>> How do you get it?
>>
>> Of course, you can instantiate beans through macros,
>> but it's "not convenient"
>>
>> I would fawor following solution:
>> define "context populators" which are implicitely
>> mapped to templates. Maybe with some kind of
>> "default behaviour" ( look at Html::Mason dhandlers
>> - though it's perl, but nevertheless nice tool )
>
>
> Isn't that what struts does?
Just to be clear what I mean - I know that struts doesn't do it exactly as
you wrote. But the basic idea is the same - a mechanism to map data objects
to template requests / action requests. Turbine has the same model,
although it is (as I understand it) programmatic rather than 'configured' as
Struts is.
This is a perfectly fine model, of course, and I think it has been done a
few times by a few people.
I think what you then will find is that it really then needs some sort of
logic/controler - more than that servlet itself. So that leads to a list of
context items and an action class. Which puts you back into the model
Struts uses.
Turbine too.
The cool thing, I think, is that nature drives you towards this application
pattern...
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
Konstantin Priblouda wrote:
> Struts is merely dispatcher servlet, but every JSP
> inits / pulls stuff separately.
Technically, Struts implements the Service-to-Worker design pattern.
This combines a Front Controller, Dispatchers, and View Helpers.
The Front Controller is the ActionServlet, which is given the matching
URIs by the container.
The Dispatchers are the Struts Actions. This are lightweight singletons,
which are used by one or more URIs (/do/something /do/somethingElse).
The Actions are invoked by the ActionServlet, and they can return a
forwarding instruction if the request needs to go somewhere else.
The View Helpers are most often JSPs, but can also be other Actions, or
something else entirely, like a VelocityServlet.
A Struts page should not create its own JavaBeans, since this is what
Actions are for. We try very hard to hand the presentation page
everything it needs on a silver platter, so that it becomes a mail merge
task with HTML chrome.
A Struts page does need to access the ActionMappings and the
MessageResouces. The mappings are used to map logical names to
application URIs, so that implementation details are not embedded in the
page. The MessageResouces are used for i18n by runtime messages (error
alerts).
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
>
> Throw in very verbose code and custom tags (which suck
> :)) and the whole fun is gone.
>
> I like model of HTML::Mason:
> Though it allows mixing of code/template
> ( which is bad, but compared to CGI... ),
> it got autohandlers - which are called
> before every "topl level" components, and "dhandlers"
> which come to play when there would be 404
>
> ( this allows using so funny URL
> like; http://foo.bar/orders/september/2534/ ->
> dnahlder from erders gets executed, and pulls from
> path info that september/2543 has to be shown .
>
> And is there is just september, just a list of all
> orders has to be shown.
>
> IMHO, having such default "velocity feeders"
> [nice term?] makes everything more structured,
> and prevents designers from creating big mess.
>
> ( Though Rickard would object, and say that those are
> in turn "readonly action" ( and they are in deed :) )
> and webwork loses this problem, but I would still
> prefer such implicit mapping... )
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Konstantin Priblouda wrote:
> I like model of HTML::Mason:
> Though it allows mixing of code/template
> ( which is bad, but compared to CGI... ),
> it got autohandlers - which are called
> before every "topl level" components, and "dhandlers"
> which come to play when there would be 404
>
> ( this allows using so funny URL
> like; http://foo.bar/orders/september/2534/ ->
> dnahlder from erders gets executed, and pulls from
> path info that september/2543 has to be shown .
>
> And is there is just september, just a list of all
> orders has to be shown.
This is merely syntactic sugar for
"showorders.action?order=september/2534". I've done this with WebWork a
couple of times, and is supersimple to do.
> IMHO, having such default "velocity feeders"
> [nice term?] makes everything more structured,
> and prevents designers from creating big mess.
And also ties the URL's somewhat tightly to your object model. It does
provide for pretty URL's but there are drawbacks (e.g. when the object
to be shown is not only identified by one string).
> ( Though Rickard would object, and say that those are
> in turn "readonly action" ( and they are in deed :) )
> and webwork loses this problem, but I would still
> prefer such implicit mapping... )
Well, making pretty URL's is really not related to WebWork or Velocity
or Struts or anything. Just a simple servlet that matches a prefix and
redirects to another URL. Syntactic sugar. Big deal.. :-/
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> Isn't that what struts does?
No, It's what I'm missing :)
Struts is merely dispatcher servlet, but every JSP
inits / pulls stuff separately.
Throw in very verbose code and custom tags (which suck
:)) and the whole fun is gone.
I like model of HTML::Mason:
Though it allows mixing of code/template
( which is bad, but compared to CGI... ),
it got autohandlers - which are called
before every "topl level" components, and "dhandlers"
which come to play when there would be 404
( this allows using so funny URL
like; http://foo.bar/orders/september/2534/ ->
dnahlder from erders gets executed, and pulls from
path info that september/2543 has to be shown .
And is there is just september, just a list of all
orders has to be shown.
IMHO, having such default "velocity feeders"
[nice term?] makes everything more structured,
and prevents designers from creating big mess.
( Though Rickard would object, and say that those are
in turn "readonly action" ( and they are in deed :) )
and webwork loses this problem, but I would still
prefer such implicit mapping... )
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 7:13 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
> --- Gabriel Sidler <si...@teamup.ch> wrote:
>> "Geir Magnusson Jr." wrote:
>> [...]
>>>> I keep thinking that a base VelocityServlet
>> seems like a perfectly valid
>>>> feature to me, and wouldn't need ties to Struts
>> or any other framework.
>>>> Just open the door to acting as an independant
>> servlet service that
>>>> chained the standard servlet contexts behind a
>> regular VelocityContext.
>>>
>>> Except that such a beastie can't stand on it's
>> own. Unlike a JSP, the
>>> velocity template has to be fed... Something has
>> to be put into the
>>> context....
>>
>> Yes, the standard servlet contexts request, session
>> and application.
>> It should be perfectly possible to write a simple
>> application this way.
>>
>> In this regard I don't see any conceptual
>> differences between JSP
>> and Velocity. Do I miss something?
>
> Yes. You miss something.
>
> In JSP you can make scriptlet somewhere near start,
> where you pull all your data from some kind of
> backend - in Velocity you need to initialize and put
> some beans in context.
>
> Say, in protected area you lite to display "hello
> foobar" where foobar is logged in user name
> ( but not his login name )
>
> You can take login name out of session, but to get
> to his real name you need some interaction with
> backend. So, there has to be bean in context
> which holds this name.
>
> How do you get it?
>
> Of course, you can instantiate beans through macros,
> but it's "not convenient"
>
> I would fawor following solution:
> define "context populators" which are implicitely
> mapped to templates. Maybe with some kind of
> "default behaviour" ( look at Html::Mason dhandlers
> - though it's perl, but nevertheless nice tool )
Isn't that what struts does?
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
--- Gabriel Sidler <si...@teamup.ch> wrote:
> "Geir Magnusson Jr." wrote:
> [...]
> > > I keep thinking that a base VelocityServlet
> seems like a perfectly valid
> > > feature to me, and wouldn't need ties to Struts
> or any other framework.
> > > Just open the door to acting as an independant
> servlet service that
> > > chained the standard servlet contexts behind a
> regular VelocityContext.
> >
> > Except that such a beastie can't stand on it's
> own. Unlike a JSP, the
> > velocity template has to be fed... Something has
> to be put into the
> > context....
>
> Yes, the standard servlet contexts request, session
> and application.
> It should be perfectly possible to write a simple
> application this way.
>
> In this regard I don't see any conceptual
> differences between JSP
> and Velocity. Do I miss something?
Yes. You miss something.
In JSP you can make scriptlet somewhere near start,
where you pull all your data from some kind of
backend - in Velocity you need to initialize and put
some beans in context.
Say, in protected area you lite to display "hello
foobar" where foobar is logged in user name
( but not his login name )
You can take login name out of session, but to get
to his real name you need some interaction with
backend. So, there has to be bean in context
which holds this name.
How do you get it?
Of course, you can instantiate beans through macros,
but it's "not convenient"
I would fawor following solution:
define "context populators" which are implicitely
mapped to templates. Maybe with some kind of
"default behaviour" ( look at Html::Mason dhandlers
- though it's perl, but nevertheless nice tool )
Say, if somebody calls template
"/foo/bar/blurge/bang.vm" execute following
populators:
ContextPopulator
foo.ContextPopulator
foo.bar.ContextPopulator
foo.bar.blurge.ContextPopulator
foo.bar.blurge.BangPopulator
if they are existing.
Of course this behaviour has to be configurable.
( and Rickard �berg will have $0.02 about this :) )
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
"Geir Magnusson Jr." wrote:
[...]
> > I keep thinking that a base VelocityServlet seems like a perfectly valid
> > feature to me, and wouldn't need ties to Struts or any other framework.
> > Just open the door to acting as an independant servlet service that
> > chained the standard servlet contexts behind a regular VelocityContext.
>
> Except that such a beastie can't stand on it's own. Unlike a JSP, the
> velocity template has to be fed... Something has to be put into the
> context....
Yes, the standard servlet contexts request, session and application.
It should be perfectly possible to write a simple application this way.
In this regard I don't see any conceptual differences between JSP
and Velocity. Do I miss something?
Gabe
> It could be an object factory so the template can start
> creating things, but still - it needs something...
>
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Peter Donald <pe...@apache.org>.
On Thu, 6 Dec 2001 08:58, Geir Magnusson Jr. wrote:
> Sung to the tune of "It's beginning to look a lot like Christmas"
>
> It's beginning to sound a lot like PageContext.
> Every where you go;
> Take a look in the CVS,
> Oh goodness, what a mess,
> With buggy code and broken JDO
>
> It's beginning to look a lot like PageContext
> Data in every map
> But our biggest problem now
> Is access, where and how
> I hope this doesn't grow to a big flap....
>
>
> (couldn't resist)
You do know that you are quite insane don't you ? ;)
--
Cheers,
Pete
----------------------------------------------------------------
Fools ignore complexity. Pragmatists suffer it.
Some can avoid it. Geniuses remove it.
-- Perlis's Programming Proverb #58, SIGPLAN Notices, Sept. 1982
----------------------------------------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 9:09 AM, "Ted Husted" <hu...@apache.org> wrote:
> "Geir Magnusson Jr." wrote:
>> Except that such a beastie can't stand on it's own. Unlike a JSP, the
>> velocity template has to be fed... Something has to be put into the
>> context.... It could be an object factory so the template can start
>> creating things, but still - it needs something...
>
> Which is beginning to sound like a PageContext.
>
>
Sung to the tune of "It's beginning to look a lot like Christmas"
It's beginning to sound a lot like PageContext.
Every where you go;
Take a look in the CVS,
Oh goodness, what a mess,
With buggy code and broken JDO
It's beginning to look a lot like PageContext
Data in every map
But our biggest problem now
Is access, where and how
I hope this doesn't grow to a big flap....
(couldn't resist)
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
"Geir Magnusson Jr." wrote:
> Except that such a beastie can't stand on it's own. Unlike a JSP, the
> velocity template has to be fed... Something has to be put into the
> context.... It could be an object factory so the template can start
> creating things, but still - it needs something...
Which is beginning to sound like a PageContext.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 8:34 PM, "Ted Husted" <hu...@apache.org> wrote:
> "Geir Magnusson Jr." wrote:
>>
>> On 12/4/01 7:21 PM, "Donnie Hale" <do...@haleonline.net> wrote:
>>
>>> I'm not strongly for or against a separate project for the integration. I'd
>>> lean toward making it an optionally-built part of velocity, myself, like
>>> "vel-struts.jar" from a new target in the build.xml file.
>>>
>>
>> I don't think that it should be a part of Velocity at all if you can
>> convince others in the struts community that having Velocity support in
>> Struts is a good thing.
>>
>> (And I think it is...)
>>
>> If there is violent opposition in Struts for it, then we should reconsider,
>> but it would be a royal pain to maintain...
>
> The only thing that might bother anyone is needing yet another JAR to
> compile something ;-) But, so long as it's an optional download or
> build, that shouldn't be a problem.
>
> I keep thinking that a base VelocityServlet seems like a perfectly valid
> feature to me, and wouldn't need ties to Struts or any other framework.
> Just open the door to acting as an independant servlet service that
> chained the standard servlet contexts behind a regular VelocityContext.
Except that such a beastie can't stand on it's own. Unlike a JSP, the
velocity template has to be fed... Something has to be put into the
context.... It could be an object factory so the template can start
creating things, but still - it needs something...
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
"Geir Magnusson Jr." wrote:
>
> On 12/4/01 7:21 PM, "Donnie Hale" <do...@haleonline.net> wrote:
>
> > I'm not strongly for or against a separate project for the integration. I'd
> > lean toward making it an optionally-built part of velocity, myself, like
> > "vel-struts.jar" from a new target in the build.xml file.
> >
>
> I don't think that it should be a part of Velocity at all if you can
> convince others in the struts community that having Velocity support in
> Struts is a good thing.
>
> (And I think it is...)
>
> If there is violent opposition in Struts for it, then we should reconsider,
> but it would be a royal pain to maintain...
The only thing that might bother anyone is needing yet another JAR to
compile something ;-) But, so long as it's an optional download or
build, that shouldn't be a problem.
I keep thinking that a base VelocityServlet seems like a perfectly valid
feature to me, and wouldn't need ties to Struts or any other framework.
Just open the door to acting as an independant servlet service that
chained the standard servlet contexts behind a regular VelocityContext.
A VelocityServlet that used the ActionResources could then be a subclass
of that.
I've already suggested that we build Struts in more finely turned JARs,
so you will be able to get the core framework without taking the tag
extensions.
The ActionVelocityServlet could then link a struts-core.jar to access
the shared resource classes, being the ActionForwards, ActionForms, and
ActionMappings. Along with the MessageResources, if they don't get
moved.
We're actually in the process of moving other packages from the contrib
folder into the Commons and/or Taglibs. David's Validator is up for a
Commons vote now, and Cedric is taking Tiles to Taglibs. If someone
wanted to spearhead a moving the MessageResources in the Commons, that
would be fine with me, so long as they are taking responsibility for the
details. We already moved the Digester and other packages over.
I think the ActionVelocityServlet could live in the Struts CVS, so long
as the VelocityServlet part of it was maintained by those who understand
that part of the codebase better.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 7:21 PM, "Donnie Hale" <do...@haleonline.net> wrote:
> I'm not strongly for or against a separate project for the integration. I'd
> lean toward making it an optionally-built part of velocity, myself, like
> "vel-struts.jar" from a new target in the build.xml file.
>
I don't think that it should be a part of Velocity at all if you can
convince others in the struts community that having Velocity support in
Struts is a good thing.
(And I think it is...)
If there is violent opposition in Struts for it, then we should reconsider,
but it would be a royal pain to maintain...
> However, I'm strongly against trying to do too much reinvention of Struts.
> This thread sounds like something close to a fork at this point (perhaps I'm
> misunderstanding). Note that there's some amount of refactoring work going
> on in Struts at present, in which I'm involved to a degree, which will
> hopefully decouple a lot of the stuff that's too tightly coupled in Struts
> to ActionServlet, etc. And my motivation is to make Struts more "view
> neutral" (read: Velocity friendly :). I know that a lot of the Struts folks
> will argue that it is view neutral already; we'll have to agree to disagree
> on that. In any case, I'd like to see that work come to fruition and then
> see where that leaves a Velocity-Struts integration effort. In the meantime,
> we can try to define and create the stuff we'll need on this side no matter
> what final form the Struts changes take (assuming they get accepted and
> committed).
+1
>
> As far as MessageResources and so forth go, I've considered ripping that out
> of Struts and sending it to the jakarta-commons project to see if they want
> to add it to the commons-collections or perhaps start a jakarta-i18n project
> with that as the beginning. As far as I can see, there's nothing
> Struts-specific in them.
+1
> FWIW...
>
> Donnie
>
>
> -----Original Message-----
> From: Konstantin Priblouda [mailto:kpriblouda@yahoo.com]
> Sent: Tuesday, December 04, 2001 8:21 AM
> To: Velocity Users List
> Subject: Re: Struts/Velocity integration
>
>
>
>> I threw one of those together a while ago. I'll see
>> if I can dig it up.
>
> would be nice ...
>
>> Hang on for a sec. I am starting to detect 'scope
>> creep'.
>>
>> Doesn't Struts already have this stuff? Isn't the
>> point to make Velocity
>> easily available to Struts users? It's cool if we
>> can also add a bunch of
>> useful formatting/utility tools, but that's
>> secondary.
>>
>> Further, you would imagine that those tools are a
>> separate thing anyway -
>> Velocity will allow you to easily access *any* tool,
>> so why not just make
>> that effortless to share tools between JSP and Vel
>> in Struts, and let the
>> 'market' decide what tools it needs...
>
> agree. we will have to figure what parts of struts are
>
> necessary ( we will have to decide on priorities )
>
>
>> Hm. Don't you want to use the existing URL
>> formatting / action stuff that
>> is in struts, and not make new ones?
>
> Yes of course. But not necessary in the same form as
> in tag libraries.
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Be a giant. Take giant steps. Do giant things...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Donnie Hale <do...@haleonline.net>.
I'm not strongly for or against a separate project for the integration. I'd
lean toward making it an optionally-built part of velocity, myself, like
"vel-struts.jar" from a new target in the build.xml file.
However, I'm strongly against trying to do too much reinvention of Struts.
This thread sounds like something close to a fork at this point (perhaps I'm
misunderstanding). Note that there's some amount of refactoring work going
on in Struts at present, in which I'm involved to a degree, which will
hopefully decouple a lot of the stuff that's too tightly coupled in Struts
to ActionServlet, etc. And my motivation is to make Struts more "view
neutral" (read: Velocity friendly :). I know that a lot of the Struts folks
will argue that it is view neutral already; we'll have to agree to disagree
on that. In any case, I'd like to see that work come to fruition and then
see where that leaves a Velocity-Struts integration effort. In the meantime,
we can try to define and create the stuff we'll need on this side no matter
what final form the Struts changes take (assuming they get accepted and
committed).
As far as MessageResources and so forth go, I've considered ripping that out
of Struts and sending it to the jakarta-commons project to see if they want
to add it to the commons-collections or perhaps start a jakarta-i18n project
with that as the beginning. As far as I can see, there's nothing
Struts-specific in them.
FWIW...
Donnie
-----Original Message-----
From: Konstantin Priblouda [mailto:kpriblouda@yahoo.com]
Sent: Tuesday, December 04, 2001 8:21 AM
To: Velocity Users List
Subject: Re: Struts/Velocity integration
> I threw one of those together a while ago. I'll see
> if I can dig it up.
would be nice ...
> Hang on for a sec. I am starting to detect 'scope
> creep'.
>
> Doesn't Struts already have this stuff? Isn't the
> point to make Velocity
> easily available to Struts users? It's cool if we
> can also add a bunch of
> useful formatting/utility tools, but that's
> secondary.
>
> Further, you would imagine that those tools are a
> separate thing anyway -
> Velocity will allow you to easily access *any* tool,
> so why not just make
> that effortless to share tools between JSP and Vel
> in Struts, and let the
> 'market' decide what tools it needs...
agree. we will have to figure what parts of struts are
necessary ( we will have to decide on priorities )
> Hm. Don't you want to use the existing URL
> formatting / action stuff that
> is in struts, and not make new ones?
Yes of course. But not necessary in the same form as
in tag libraries.
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> I threw one of those together a while ago. I'll see
> if I can dig it up.
would be nice ...
> Hang on for a sec. I am starting to detect 'scope
> creep'.
>
> Doesn't Struts already have this stuff? Isn't the
> point to make Velocity
> easily available to Struts users? It's cool if we
> can also add a bunch of
> useful formatting/utility tools, but that's
> secondary.
>
> Further, you would imagine that those tools are a
> separate thing anyway -
> Velocity will allow you to easily access *any* tool,
> so why not just make
> that effortless to share tools between JSP and Vel
> in Struts, and let the
> 'market' decide what tools it needs...
agree. we will have to figure what parts of struts are
necessary ( we will have to decide on priorities )
> Hm. Don't you want to use the existing URL
> formatting / action stuff that
> is in struts, and not make new ones?
Yes of course. But not necessary in the same form as
in tag libraries.
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 6:19 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
>> I would keep this as a sub-project of Velocity for
>> now. Currently,
>> there's more understanding of this topic within the
>> Velocity community
>> than in the Struts community. Fortunately we have
>> one of the Struts
>> gurus reading and contributing on this list.
>> Implementation details
>> can be discussed offline. If needed I can provide
>> server space until
>> we have a version that can be moved to the Velocity
>> or Struts web site.
>
> Agree. What we need is generally usable servlet,
> which can be easily adapted to whatever framework
> user like.
>
>
> BTW, nothing prevents us from starting project on
> sourceforge - it's easiest way to get thing up and
> running.
>
> And we can always move back to jakarta.
>
>> Are you refering here to a VelocityServlet, for
>> example?
>
> Somehow. VelocityServlet is nice example how to do
> this, but not very advanced.
>
> There are still topics to be adressed:
> - resource loader more suitable for servlet context
> ( than FilreResourceLodaer ).
> This one has to be ServletContext aware, and use
> getResourceAsStream from there
> ( see my arguments with Rickard )
>
> I did it already, but not sure I got ServletContext
> passing "the right way". I passed it through static
> class member and updated on every servlet invocation.
>
> Is there convenient way to get ServletContext inside
> servlet environment just for currently executing
> thread (if any) without asking request/response?
>
I threw one of those together a while ago. I'll see if I can dig it up.
>
>
>
>> Yes, but I see this as a second priority. Such beans
>> are
>> useful independent of Struts, right?
>
>
> Certainly :) We can steal a lot of usefull stuff
> from Turbine ( skinnable UI stuff :) ), webwork
> ( date/number formatters )...
Hang on for a sec. I am starting to detect 'scope creep'.
Doesn't Struts already have this stuff? Isn't the point to make Velocity
easily available to Struts users? It's cool if we can also add a bunch of
useful formatting/utility tools, but that's secondary.
Further, you would imagine that those tools are a separate thing anyway -
Velocity will allow you to easily access *any* tool, so why not just make
that effortless to share tools between JSP and Vel in Struts, and let the
'market' decide what tools it needs...
>
>>>
>>> What else?
>>
>> - Support for Velocity templates as drop-in
>> replacements for
>> JSP templates. A Struts application can mix the use
>> of
>> JSP templates and Velocity templates.
>
> Provided we got servlet ( relatively easy ) and
> some of struts functionality integrated in adapter
> class - I see no problem with it.
>
>> - Come up with a solution that does not require any
>> changes
>> to Struts.
>
> Agree.
>
>> - In Velocity: Provide equivalent alternatives to
>> the basic
>> JSP features (where meaningful). This might require
>> the development
>> of some context tools or Velocimacros.
>
> It's difficult decision, what's meaningfull :)
>
>> - In Velocity: Provide equivalent alternatives to
>> the BEAN,
>> HTML, LOGIC and TEMPLATE tag libraries. I would
>> favor an approach
>> in phases. We need to look at the importance of the
>> tags and
>> define priorities. I am sure Ted will be able to
>> provide us
>> some useful input here. For example, the form tags
>> are a second
>> priority in my view.
>
> IMHO, logic and template tags are lowest priority [if
> any]. Velocity provides meaningfull alternatives ( in
> klartext: die k?nnen mir gestohlen bleiben :)
>
> html tags are somtimes nice, but most important aspect
> in struts is URL formatting ( with actions etc ) ->
> can be stole from request utils I think.
> ( for links and form actions )
Hm. Don't you want to use the existing URL formatting / action stuff that
is in struts, and not make new ones?
Don't get me wrong - if you are making a new framework, have a blast (but
don't count me in... I'm not a framework guy...)
But that is different than Struts integration.
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> I would keep this as a sub-project of Velocity for
> now. Currently,
> there's more understanding of this topic within the
> Velocity community
> than in the Struts community. Fortunately we have
> one of the Struts
> gurus reading and contributing on this list.
> Implementation details
> can be discussed offline. If needed I can provide
> server space until
> we have a version that can be moved to the Velocity
> or Struts web site.
Agree. What we need is generally usable servlet,
which can be easily adapted to whatever framework
user like.
BTW, nothing prevents us from starting project on
sourceforge - it's easiest way to get thing up and
running.
And we can always move back to jakarta.
> Are you refering here to a VelocityServlet, for
> example?
Somehow. VelocityServlet is nice example how to do
this, but not very advanced.
There are still topics to be adressed:
- resource loader more suitable for servlet context
( than FilreResourceLodaer ).
This one has to be ServletContext aware, and use
getResourceAsStream from there
( see my arguments with Rickard )
I did it already, but not sure I got ServletContext
passing "the right way". I passed it through static
class member and updated on every servlet invocation.
Is there convenient way to get ServletContext inside
servlet environment just for currently executing
thread (if any) without asking request/response?
> Yes, but I see this as a second priority. Such beans
> are
> useful independent of Struts, right?
Certainly :) We can steal a lot of usefull stuff
from Turbine ( skinnable UI stuff :) ), webwork
( date/number formatters )...
> >
> > What else?
>
> - Support for Velocity templates as drop-in
> replacements for
> JSP templates. A Struts application can mix the use
> of
> JSP templates and Velocity templates.
Provided we got servlet ( relatively easy ) and
some of struts functionality integrated in adapter
class - I see no problem with it.
> - Come up with a solution that does not require any
> changes
> to Struts.
Agree.
> - In Velocity: Provide equivalent alternatives to
> the basic
> JSP features (where meaningful). This might require
> the development
> of some context tools or Velocimacros.
It's difficult decision, what's meaningfull :)
> - In Velocity: Provide equivalent alternatives to
> the BEAN,
> HTML, LOGIC and TEMPLATE tag libraries. I would
> favor an approach
> in phases. We need to look at the importance of the
> tags and
> define priorities. I am sure Ted will be able to
> provide us
> some useful input here. For example, the form tags
> are a second
> priority in my view.
IMHO, logic and template tags are lowest priority [if
any]. Velocity provides meaningfull alternatives ( in
klartext: die k�nnen mir gestohlen bleiben :)
html tags are somtimes nice, but most important aspect
in struts is URL formatting ( with actions etc ) ->
can be stole from request utils I think.
( for links and form actions )
bean tags - [form] bean instanciation, message
retrival
> - Documentation for the Velocity developer.
very Important, but there is already velocity
documentation.
>
> - Documentation for the Struts developer (with a
> detailed table
> comparing the JSP-way and the Velocity-way to
> implement the various
> aspects of a template.
very important.
> Some general comments:
> - I favor very much an approach in short phases.
> Let's get something
> working soon and build on that in small steps.
Me too. I already have some stuff ready, but I will
be unable to hack on it until friday ( I'm sitting at
the bank, and have merely access to my email :) )
> - Let's not try to integrate Velocity/Struts,
> improve Struts
> and redesign JSP at the same time :-).
Agree
> I believe
> that in a first
> approach we should try to stick as closely as
> possible to the
> philosophies of Struts. I understand that some
> people on this list
> have more advanced views of how a templating
> solution should be
> designed...
Yes yes yes...
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Konstantin Priblouda wrote:
[...]
> First, we need to determine scope of the project:
> - is it more subprojects of velocity
> - is it subproject of struts
> - is it somehow standalone project
I would keep this as a sub-project of Velocity for now. Currently,
there's more understanding of this topic within the Velocity community
than in the Struts community. Fortunately we have one of the Struts
gurus reading and contributing on this list. Implementation details
can be discussed offline. If needed I can provide server space until
we have a version that can be moved to the Velocity or Struts web site.
> What I would like to achieve:
>
> - Using velocity templating in convenient way
> (almost done with VelocityServlet, but some issues
> remain - notably template loading. We will need
> resource loader which loads not from file,
> but from Servlets "getResourceAsStream()" ->
> this is more servletish )
>
> - Adapter objects for different frameworks, which can
> be plugged in ( in first line struts, webwork
> guys can care for themselves :) )
Are you refering here to a VelocityServlet, for example?
>
> - library of usefull beans to be used in templates
> ( for example different number/date formatters )
Yes, but I see this as a second priority. Such beans are
useful independent of Struts, right?
>
> What else?
- Support for Velocity templates as drop-in replacements for
JSP templates. A Struts application can mix the use of
JSP templates and Velocity templates.
- Come up with a solution that does not require any changes
to Struts.
- In Velocity: Provide equivalent alternatives to the basic
JSP features (where meaningful). This might require the development
of some context tools or Velocimacros.
- In Velocity: Provide equivalent alternatives to the BEAN,
HTML, LOGIC and TEMPLATE tag libraries. I would favor an approach
in phases. We need to look at the importance of the tags and
define priorities. I am sure Ted will be able to provide us
some useful input here. For example, the form tags are a second
priority in my view.
- Documentation for the Velocity developer.
- Documentation for the Struts developer (with a detailed table
comparing the JSP-way and the Velocity-way to implement the various
aspects of a template.
Some general comments:
- I favor very much an approach in short phases. Let's get something
working soon and build on that in small steps.
- Let's not try to integrate Velocity/Struts, improve Struts
and redesign JSP at the same time :-). I believe that in a first
approach we should try to stick as closely as possible to the
philosophies of Struts. I understand that some people on this list
have more advanced views of how a templating solution should be
designed... My primary motivation is to create a new templating
option for Struts, not to create a new Struts :-).
Gabe
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Geir Magnusson Jr. wrote:
> Or we can use WebWork to allow integration of Velocity into Struts, and call
> it
>
> WebStrocity
>
> Or something :)
That would probably be a trocity though ;-)
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 3:57 AM, "Rickard Öberg" <ri...@xpedio.com> wrote:
>
> WebWork has a number of useful beans that can be used. For example,
> number/date formatters, counters, iterator filters (sorters, appenders,
> mergers, etc.), and so on. Steal or use as-is.
>
> Or simply use Velocity with WebWork and be done with it ;-)
>
Or we can use WebWork to allow integration of Velocity into Struts, and call
it
WebStrocity
Or something :)
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 6:47 AM, "Peter Donald" <pe...@apache.org> wrote:
> On Tue, 4 Dec 2001 22:30, Konstantin Priblouda wrote:
>>> But, that's VelocityServlet to me. That is what I
>>> subclass to get the
>>> WebWork specific thing in...
>>
>> Well, VelocityServlet is just an example how to do it.
>>
>> It could be made better, and more "generic"...
>
> One thing that may be an idea is to stuff in the request / session /
> application objects because thats what jsp developers expect to use. I
> managed to convince some people to convert to velocity just by doing that and
> letting them play for a bit ;)
They already are there in the default context provided in
VelocityServlet....
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Peter Donald <pe...@apache.org>.
On Tue, 4 Dec 2001 22:30, Konstantin Priblouda wrote:
> > But, that's VelocityServlet to me. That is what I
> > subclass to get the
> > WebWork specific thing in...
>
> Well, VelocityServlet is just an example how to do it.
>
> It could be made better, and more "generic"...
One thing that may be an idea is to stuff in the request / session /
application objects because thats what jsp developers expect to use. I
managed to convince some people to convert to velocity just by doing that and
letting them play for a bit ;)
--
Cheers,
Pete
------------------------------------------------------------
I just got lost in thought... It was unfamiliar territory.
------------------------------------------------------------
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> But, that's VelocityServlet to me. That is what I
> subclass to get the
> WebWork specific thing in...
Well, VelocityServlet is just an example how to do it.
It could be made better, and more "generic"...
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Konstantin Priblouda wrote:
> You are mixing up getResourceAsStrem() from
> classloader
> and getResourceAsStream() from ServletContext.
>
> They are not the same ( and ther is even warning
> against mixing them up in javadoc :) )
>
> While one from classloaer loads from classpath,
> the one from ServletContext does "the right thing"
> and loads from where it's residing.
>
> Consult source of default servlet
> ( btw, my proposal of 404ing /WEB_INF/* /META-INF/*
> also comes from there :) )
Ah :-) Good!
>>What I meant was that *Velocity* does not need a
>>WebWork adapter, since
>>WebWork already has one. It is better to have
>>dependencies from WW to
>>Velocity, than the other way round, since Velocity
>>should be a generic
>>templating engine and not tied to any particular
>>framework.
>>
>
> Well, that's exactly my idea - let's have velocity
> servlet usable without any hassles/dependencies of
> framework with possibility to configure servlet
> to be able to populate context with whatever
> objects we see fit.
But, that's VelocityServlet to me. That is what I subclass to get the
WebWork specific thing in...
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> AFAICT the only problem comes when the app *is* WAR
> archived, because
> then the templates has to be extracted from within
> the archive. If the
> WAR is expanded on deploy (which at least Tomcat and
> Resin and Orion
> does) then there's no problem, since you can easily
> have the servlet set
> up the root directory.
>
> Furthermore, using getResourceAsStream() is actually
> worse since then
> your templates have to be under WEB-INF/classes or
> in /WEB-INF/lib
> archives, since those are the only places
> getResourceAsStream works with
> (normal classloading).
You are mixing up getResourceAsStrem() from
classloader
and getResourceAsStream() from ServletContext.
They are not the same ( and ther is even warning
against mixing them up in javadoc :) )
While one from classloaer loads from classpath,
the one from ServletContext does "the right thing"
and loads from where it's residing.
Consult source of default servlet
( btw, my proposal of 404ing /WEB_INF/* /META-INF/*
also comes from there :) )
> What I meant was that *Velocity* does not need a
> WebWork adapter, since
> WebWork already has one. It is better to have
> dependencies from WW to
> Velocity, than the other way round, since Velocity
> should be a generic
> templating engine and not tied to any particular
> framework.
Well, that's exactly my idea - let's have velocity
servlet usable without any hassles/dependencies of
framework with possibility to configure servlet
to be able to populate context with whatever
objects we see fit.
> > There are still situations where no framework is
> > necessary :)
>
>
> Such as? (You may be right, I just don't know)
Trivial applications :)
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Konstantin Priblouda wrote:
>>Look at the WebworkVelocityServlet, which does it in
>>a convenient way.
>>
>
> It's convenient, but it still does "the wrong thing"
> It relies on FileResourceLoader. Which des not do it.
>
> If you use war archive, everything is fine,
> but not if you use expanded format and set doc base
> in context -> you still have to setup
> root diretory for fileResourceLoader in properties.
AFAICT the only problem comes when the app *is* WAR archived, because
then the templates has to be extracted from within the archive. If the
WAR is expanded on deploy (which at least Tomcat and Resin and Orion
does) then there's no problem, since you can easily have the servlet set
up the root directory.
Furthermore, using getResourceAsStream() is actually worse since then
your templates have to be under WEB-INF/classes or in /WEB-INF/lib
archives, since those are the only places getResourceAsStream works with
(normal classloading).
> Well, but WebWork specific way.
What I meant was that *Velocity* does not need a WebWork adapter, since
WebWork already has one. It is better to have dependencies from WW to
Velocity, than the other way round, since Velocity should be a generic
templating engine and not tied to any particular framework.
> I would prefer to see velocity as general templating
> tool not depending on whatever framework.
Agree, see above.
> There are still situations where no framework is
> necessary :)
Such as? (You may be right, I just don't know)
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
--- Rickard �berg <ri...@xpedio.com> wrote:
> Hehe, sorry to chip in again.. can't...he..lp..it..
You are welcome :)
> > - Using velocity templating in convenient way
> > (almost done with VelocityServlet, but some issues
> > remain - notably template loading. We will need
> > resource loader which loads not from file,
> > but from Servlets "getResourceAsStream()" ->
> > this is more servletish )
>
>
> Look at the WebworkVelocityServlet, which does it in
> a convenient way.
It's convenient, but it still does "the wrong thing"
It relies on FileResourceLoader. Which des not do it.
If you use war archive, everything is fine,
but not if you use expanded format and set doc base
in context -> you still have to setup
root diretory for fileResourceLoader in properties.
> > - Adapter objects for different frameworks, which
> can
> > be plugged in ( in first line struts, webwork
> > guys can care for themselves :) )
>
>
> Adapter objects? Blah, don't need that with WebWork.
> Any WW integration
> is already done.
Well, but WebWork specific way. While webwork is cool,
not everybody is able to switch for it
(due to complete lack of documentation).
> WebWork has a number of useful beans that can be
> used. For example,
> number/date formatters, counters, iterator filters
> (sorters, appenders,
> mergers, etc.), and so on. Steal or use as-is.
It's already being considered :)
> Or simply use Velocity with WebWork and be done with
> it ;-)
well, not an option ot the moment :)
I would prefer to see velocity as general templating
tool not depending on whatever framework.
There are still situations where no framework is
necessary :)
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Rickard Öberg <ri...@xpedio.com>.
Hehe, sorry to chip in again.. can't...he..lp..it..
Konstantin Priblouda wrote:
> What I would like to achieve:
>
> - Using velocity templating in convenient way
> (almost done with VelocityServlet, but some issues
> remain - notably template loading. We will need
> resource loader which loads not from file,
> but from Servlets "getResourceAsStream()" ->
> this is more servletish )
Look at the WebworkVelocityServlet, which does it in a convenient way.
> - Adapter objects for different frameworks, which can
> be plugged in ( in first line struts, webwork
> guys can care for themselves :) )
Adapter objects? Blah, don't need that with WebWork. Any WW integration
is already done.
> - library of usefull beans to be used in templates
> ( for example different number/date formatters )
WebWork has a number of useful beans that can be used. For example,
number/date formatters, counters, iterator filters (sorters, appenders,
mergers, etc.), and so on. Steal or use as-is.
Or simply use Velocity with WebWork and be done with it ;-)
/Rickard
--
Rickard Öberg
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 8:23 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
>> Right - the ClasspathResourceLoader does this, or I
>> can throw together a
>> ServletResourceLoader (riff on the above)....
>
> I already have vesrion doing it. The only thing
> remaining is meaningfull ( correct )
> passing of servlet context.
> IMHO - such resource loader ought to be part of
> velocity :)
Yeah, we've been back and forth on this one...
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> Right - the ClasspathResourceLoader does this, or I
> can throw together a
> ServletResourceLoader (riff on the above)....
I already have vesrion doing it. The only thing
remaining is meaningfull ( correct )
passing of servlet context.
IMHO - such resource loader ought to be part of
velocity :)
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 3:44 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
> --- Gabriel Sidler <si...@teamup.ch> wrote:
>> Konstantin,
>> I would be happy to work with you on this.
>
> Well, we can start.
>
> First, we need to determine scope of the project:
> - is it more subprojects of velocity
> - is it subproject of struts
> - is it somehow standalone project
Since we are talking struts integration, you would think that these would be
bits and pieces that hopefully wind up in struts, although we can work here
for now.
If they don't want them in Struts, I guess we host it here for the
community, but we should try to avoid that outcome.
Velocity isn't a framework...
>
> What I would like to achieve:
>
> - Using velocity templating in convenient way
> (almost done with VelocityServlet, but some issues
> remain - notably template loading. We will need
> resource loader which loads not from file,
> but from Servlets "getResourceAsStream()" ->
> this is more servletish )
Right - the ClasspathResourceLoader does this, or I can throw together a
ServletResourceLoader (riff on the above)....
>
> - Adapter objects for different frameworks, which can
> be plugged in ( in first line struts, webwork
> guys can care for themselves :) )
I dunno. It sounds like the webworkers have a bunch of stuff that could be
used for this.
> - library of usefull beans to be used in templates
> ( for example different number/date formatters )
Yep. There already is a start to this over in commons-sandbox/rupert, with
contribtions from Christoph and Nathan.
>
> What else?
>
> regards,
>
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Be a giant. Take giant steps. Do giant things...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
--- Gabriel Sidler <si...@teamup.ch> wrote:
> Konstantin,
> I would be happy to work with you on this.
Well, we can start.
First, we need to determine scope of the project:
- is it more subprojects of velocity
- is it subproject of struts
- is it somehow standalone project
What I would like to achieve:
- Using velocity templating in convenient way
(almost done with VelocityServlet, but some issues
remain - notably template loading. We will need
resource loader which loads not from file,
but from Servlets "getResourceAsStream()" ->
this is more servletish )
- Adapter objects for different frameworks, which can
be plugged in ( in first line struts, webwork
guys can care for themselves :) )
- library of usefull beans to be used in templates
( for example different number/date formatters )
What else?
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Konstantin,
I would be happy to work with you on this.
Gabe
Konstantin Priblouda wrote:
>
> Well, there was a lot of discussion about it.
>
> What about to start doing something? :)
>
> I played around today:
>
> - Subclassed velocity servlet and added
> "StrutsUtil" object to context.
>
> - Implemented ( partially ) method message()
> to get functionality like <bean:message> -
> was really easy, most of code can be stolen
> from RequestUtils, with zapping all jspish
> stuff ( notably PageContext)
>
> It worked perfectly ( and was easy )
>
> anybody to join me?
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
If you want to get the path from the Struts mapping, then, yes, the
resource object would return that. Assuming that the ActionResources
are in a runtime object named shared.
ActionForward forward = shared.getActionForward("name");
It would probably be best if the VelServlet did the actual forwarding
(or include), with some method like
protected void processActionForward(ActionForward forward,
ActionResources shared,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
if (forward != null) {
String path = forward.getPath();
if (forward.getRedirect()) {
if (path.startsWith("/"))
path = request.getContextPath() + path;
response.sendRedirect(response.encodeRedirectURL(path));
} else {
RequestDispatcher rd =
getServletContext().getRequestDispatcher(path);
if (rd == null) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
shared.getMessages().getMessage(
"requestDispatcher",path));
return;
}
rd.forward(request, response);
}
}
Of course, I just cribbed this from ActionServlet ;O)
But, yeah, I'll finish up on a milestone for tomorrow, and then put that
together.
Peter Donald wrote:
>
> On Mon, 3 Dec 2001 06:59, Ted Husted wrote:
> > I'll write a class that will provide an API to the Struts resources,
> > from anywhere in the application, if someone tells that it will do any
> > good ;0)
>
> It will help me ! ;)
>
> Add in ability to forward to named resources then I would be all set ;)
>
> --
> Cheers,
>
> Pete
>
> *-----------------------------------------------------*
> | Never argue with an idiot, they'll drag you down to |
> | their level, and beat you with experience |
> *-----------------------------------------------------*
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Peter Donald <pe...@apache.org>.
On Mon, 3 Dec 2001 06:59, Ted Husted wrote:
> I'll write a class that will provide an API to the Struts resources,
> from anywhere in the application, if someone tells that it will do any
> good ;0)
It will help me ! ;)
Add in ability to forward to named resources then I would be all set ;)
--
Cheers,
Pete
*-----------------------------------------------------*
| Never argue with an idiot, they'll drag you down to |
| their level, and beat you with experience |
*-----------------------------------------------------*
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
I'll write a class that will provide an API to the Struts resources,
from anywhere in the application, if someone tells that it will do any
good ;0)
Konstantin Priblouda wrote:
>
> Well, there was a lot of discussion about it.
>
> What about to start doing something? :)
Ted Husted wrote:
> We could define a Struts Resources API easily enough. Here's what an
> interface might look like.
>
> public interface StrutsResources {
>
> public void setResourceRequest(HttpServletRequest request);
>
> public DataSource getDataSource();
> public ActionErrors getActionErrors();
> public Throwable getException();
> public ActionFormBeans getActionFormBeans();
> public ActionForwards getActionForwards();
> public Locale getLocale();
> public ActionMappings getActionMappings();
> public MessageResources getMessageResouces();
> public DiskMultipartRequestHandler getMultipartHandler();
> public ActionServlet getActionServlet();
> public Servlet getServlet();
> public String getToken();
>
> public ActionForm getActionForm(String name);
> public ActionForward getActionForward(String name);
> public ActionMapping getActionMapping(String name);
>
> public ActionMapping getCurrentMapping();
> public ActionForm getCurrentActionForm();
>
> }
>
> This would just be a wrapper that returned whatever from whatever
> context. Most if it is just calling request.getAttribute($(*}_KEY).
>
> -T.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
Chaining just seemed like the simplest thing.
Struts developers use the session and request contexts like a
VelocityContext, so why not make them VelocityContexts?
As I understand it, the chaining mechanism provides the same default
scoping developers are used to, and it seems like an ideal match.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
Gabriel Sidler wrote:
>
> Ted Husted wrote:
> [...]
> > So, the other first step, along with Donnie's bean, I think, is to chain
> > the request, session, and application contexts to a VelocityContext,
> > behind a facade.
>
> Ted,
> you have mentioned in several of your posts the idea of chaining the
> request, session and application scopes. I understand this such that
> on lookup of a bean first the request scope is searched, then the
> session scope is searched and finally the application scope is searched.
> (Similar to what PageContext.findAttribute() does)
>
> Can you elaborate on why you feel that chaining the servlet scopes is
> useful/necessary? The alternative I see is to just stick request, session
> and application objects into the Velocity context.
>
> Gabe
>
> --
> Gabriel Sidler
> Software Engineer, Eivycom GmbH, Zurich, Switzerland
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Mike Williams <mi...@cortexebusiness.com.au>.
>>> On Wed, 05 Dec 2001 14:10:40 -0500,
>>> "Ted" == Ted Husted <hu...@apache.org> wrote:
Ted> If VelocityServlet can expose [request and session contexts]
Ted> transparently, then a Velocity template can be dropped-in where a
Ted> JSP is being used now.
+1. That would be way cool.
Ted> So, at the same time, I would also recommend that it be possible for
Ted> a developer to create a VelocityContext in a Struts Action, and then
Ted> pass that along (errr, in the request). The VelServlet could then
Ted> adopt that as the base context (instead of creating a new one).
Sorry, but that seems like needless complexity. I think that simply
placing $request/$response into the context should be sufficient.
--
cheers, Mike
"And so, may evil beware, and may good dress warmly and eat lots
of fresh vegetables."
-- The Tick
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Donnie Hale <do...@haleonline.net>.
See below...
Donnie
> -----Original Message-----
> From: Ted Husted [mailto:husted@apache.org]
> Sent: Wednesday, December 05, 2001 9:02 PM
> To: Velocity Users List
> Subject: Re: Struts/Velocity integration
>
>
> Donnie Hale wrote:
> >
> > >> So, at the same time, I would also recommend that it be
> possible for a
> > >> developer to create a VelocityContext in a Struts Action,
> and then pass
> > >> that along (errr, in the request). The VelServlet could then
> adopt that
> > >> as the base context (instead of creating a new one).
> > >+1 Yes. Yes. Yes!
> >
> > An earlier message in this thread (don't recall who) indicated
> that dealing
> > with the VelocityContext in an Action, something I'd proposed, was "bad"
> > since it put stuff that was presentation-specific into the
> "M-C" side of the
> > world. Don't know if I agree, but the sentiment was expressed.
> >
> > I'm still catching up on the thread, but this seems a good as
> place as any
> > to throw out an idea I've had.
> >
> > I'll start off by stating that I'd like the solution (or at least *a*
> > solution) not expose everything that's in each of the contexts
> for possible
> > use in the templates. I just don't like, so there! :) As some have
> > expressed, I'd like the data available to a template to be just what the
> > template needs and no more (within the common-sense limits of
> reusability,
> > etc.).
>
> I think the only thing that would be bad would be an either/or
> proposition. As it stands, I would support both behaviors. The
> request/session facade could be off by default, but could be enabled in
> the web.xml, depending on what a team needs to do.
>
> If you require that a Struts developer use the VelocityContext even to
> gives this a try, then it won't happen nearly as often. If they can plug
> in a Velocity template, where they are now using a JSP, then it will
> start to happen more often. I think it may happen *alot*, but we need to
> keep the bar low.
If we define the "Struts developer" as the person working in "Action-land"
(i.e. before a forward to whatever VelServlet is), then I agree with this.
And what I proposed wouldn't require them to use a VelocityContext.
Adding to my earlier message, I'd want the VelServlet to extract the bean
from the request and automatically populate a VelocityContext in a way
supporting either/both of the mechanisms I mentioned.
So:
- the "Struts developer" deals with ActionForms and Actions as (s)he does
now; (s)he has the hopefully benign imposition of sticking a bean with the
template's API into the request using a configurable, well-known name
- the template developer works as (s)he does now, from a well-defined API
for the page in question
- in the normal case, no code needs written to populate the VelocityContext
>
>
> > I'll also mention that there's going to have to be some
> coupling b/w Action
> > and whatever shape a StrutsVelocityServlet and resulting VelocityContext
> > takes.
>
> If we don't *require* a VelocityContext, then there will be no coupling
> between an Action and Velocity.
There's got to be a VelocityContext at template processing time, doesn't
there? The question is just whether any code has to be written at the app
level to fill the context. Right?
>
> A StrutsVelServlet can get everything it needs out of the current
> request, or the servletcontext, which all servlets in an application
> share, ActionServlet and ActionVelServlet alike.
>
> The only coupling between Struts and VelServlet would happen in the
> struts-config.xml, where it would start to say thisPage.vm instead of
> thisPage.jsp.
>
> Of course, if a team *chooses* to use a VelocityContext, they are only
> an import away.
>
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
Donnie Hale wrote:
>
> >> So, at the same time, I would also recommend that it be possible for a
> >> developer to create a VelocityContext in a Struts Action, and then pass
> >> that along (errr, in the request). The VelServlet could then adopt that
> >> as the base context (instead of creating a new one).
> >+1 Yes. Yes. Yes!
>
> An earlier message in this thread (don't recall who) indicated that dealing
> with the VelocityContext in an Action, something I'd proposed, was "bad"
> since it put stuff that was presentation-specific into the "M-C" side of the
> world. Don't know if I agree, but the sentiment was expressed.
>
> I'm still catching up on the thread, but this seems a good as place as any
> to throw out an idea I've had.
>
> I'll start off by stating that I'd like the solution (or at least *a*
> solution) not expose everything that's in each of the contexts for possible
> use in the templates. I just don't like, so there! :) As some have
> expressed, I'd like the data available to a template to be just what the
> template needs and no more (within the common-sense limits of reusability,
> etc.).
I think the only thing that would be bad would be an either/or
proposition. As it stands, I would support both behaviors. The
request/session facade could be off by default, but could be enabled in
the web.xml, depending on what a team needs to do.
If you require that a Struts developer use the VelocityContext even to
gives this a try, then it won't happen nearly as often. If they can plug
in a Velocity template, where they are now using a JSP, then it will
start to happen more often. I think it may happen *alot*, but we need to
keep the bar low.
> I'll also mention that there's going to have to be some coupling b/w Action
> and whatever shape a StrutsVelocityServlet and resulting VelocityContext
> takes.
If we don't *require* a VelocityContext, then there will be no coupling
between an Action and Velocity.
A StrutsVelServlet can get everything it needs out of the current
request, or the servletcontext, which all servlets in an application
share, ActionServlet and ActionVelServlet alike.
The only coupling between Struts and VelServlet would happen in the
struts-config.xml, where it would start to say thisPage.vm instead of
thisPage.jsp.
Of course, if a team *chooses* to use a VelocityContext, they are only
an import away.
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Donnie Hale <do...@haleonline.net>.
>> So, at the same time, I would also recommend that it be possible for a
>> developer to create a VelocityContext in a Struts Action, and then pass
>> that along (errr, in the request). The VelServlet could then adopt that
>> as the base context (instead of creating a new one).
>+1 Yes. Yes. Yes!
An earlier message in this thread (don't recall who) indicated that dealing
with the VelocityContext in an Action, something I'd proposed, was "bad"
since it put stuff that was presentation-specific into the "M-C" side of the
world. Don't know if I agree, but the sentiment was expressed.
I'm still catching up on the thread, but this seems a good as place as any
to throw out an idea I've had.
I'll start off by stating that I'd like the solution (or at least *a*
solution) not expose everything that's in each of the contexts for possible
use in the templates. I just don't like, so there! :) As some have
expressed, I'd like the data available to a template to be just what the
template needs and no more (within the common-sense limits of reusability,
etc.).
I'll also mention that there's going to have to be some coupling b/w Action
and whatever shape a StrutsVelocityServlet and resulting VelocityContext
takes.
Given that, what if the Action placed a bean in the request context which
exposed an API representing all the stuff that should go in the
VelocityContext? This would include things like ActionErrors,
MessageResources, etc., as appropriate for the request. I'm guessing we
could do helper (base ?) classes for those beans. The Velocity side of the
world would need to know one thing - the name that the bean was stored as in
the request. At that point, I believe, there are a couple of ways to get at
that API from the templates:
1) Put the bean in the context by name:
$beanName.getMessage("message.resource.id")
2) Introspect on the bean and add all accessible items by name to the
context:
$message("message.resource.id") ## syntax??
The point is that the bean *is* the available API, not any little piece of
cruft that's lying around in the session context for who-knows-what reason.
I hope that's clear,
Donnie
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Tim Colson <tc...@cisco.com>.
Ted / All -
Ted Husted wrote:
> A critical point is that the Velocity templates should be drop-in
> replacements for other presentation devices, like a JSP.
+1
> If VelocityServlet can expose these transparently, then a Velocity
> template can be dropped-in where a JSP is being used now. I can't
> under-emphasize how important that would be in getting teams to switch
> over to a Velocity template.
+1
> Perhaps at first because the JSP was so
> complex that it has run into memory contraints. And then later because
> it became apparent that the templates are lighter, faster, and better.
:-) That's gotta be about the nicest thing I've heard somebody say about
Velocity.
> So, at the same time, I would also recommend that it be possible for a
> developer to create a VelocityContext in a Struts Action, and then pass
> that along (errr, in the request). The VelServlet could then adopt that
> as the base context (instead of creating a new one).
+1 Yes. Yes. Yes!
> If JSP are not being used at all, then the VelocityServlet could be
> given a switch to turn off standard context chaining, and just look to
> the VelocityContext provided by the Action class (or other component).
> Or, perhaps the default can be no chaining, and it is something that we
> can turn on in a mixed environment.
+1 Fantastic.
The option to turn on/off context chaining would ideal.
Ok - now I want to know:
What is on the task list that I can help do???
No task too small - I'll happily code, or document, or even write templates
for an example (maybe add on an extra action to demonstrate using
Struts-Simple.war w/ VelServlet?)
Cheers,
Tim Colson
IT Engineer
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/5/01 2:10 PM, "Ted Husted" <hu...@apache.org> wrote:
> It would do the equivalent of
>
> Object object = null;
>
> object = velocityContext.getAttribute("foo");
>
> if (object!=null)
> object = request.getAttribute("foo");
> if (object!=null)
> object = session.getAttribute("foo");
>
> // .. reflect object.getWhatever();
There's a Context I threw into Veltag that should do that automatically...
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Tim Colson <tc...@cisco.com>.
Ted -
> It would do the equivalent of
> Object object = null;
> object = velocityContext.getAttribute("foo");
> if (object!=null)
> object = request.getAttribute("foo");
> if (object!=null)
> object = session.getAttribute("foo");
> // .. reflect object.getWhatever();
> But I wouldn't say a that page needs to call any other methods on the
> request or session API, unless Velocity already provides this.
Yes - I agree. Actually, I meant to express what you did above, but confused
the issue by making the pseudo code look like Velocity syntax. Apologies.
> > As I see it - chaining would be so Designers can chant $foo and
> > VelStrutServletThingy would automagically chant $request.foo ->
> > $session.foo -> $application.foo before giving up.
Tim
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
It would do the equivalent of
Object object = null;
object = velocityContext.getAttribute("foo");
if (object!=null)
object = request.getAttribute("foo");
if (object!=null)
object = session.getAttribute("foo");
// .. reflect object.getWhatever();
But I wouldn't say a that page needs to call any other methods on the
request or session API, unless Velocity already provides this.
If possible, the chained contexts could also be read-only.
A critical point is that the Velocity templates should be drop-in
replacements for other presentation devices, like a JSP. Right now, a
Struts developer is expected and encouraged to place objects in the
request for the use of the presentation layer. IMHO, that's why the
request and session contexts exist.
If VelocityServlet can expose these transparently, then a Velocity
template can be dropped-in where a JSP is being used now. I can't
under-emphasize how important that would be in getting teams to switch
over to a Velocity template. Perhaps at first because the JSP was so
complex that it has run into memory contraints. And then later because
it became apparent that the templates are lighter, faster, and better.
So, at the same time, I would also recommend that it be possible for a
developer to create a VelocityContext in a Struts Action, and then pass
that along (errr, in the request). The VelServlet could then adopt that
as the base context (instead of creating a new one).
If JSP are not being used at all, then the VelocityServlet could be
given a switch to turn off standard context chaining, and just look to
the VelocityContext provided by the Action class (or other component).
Or, perhaps the default can be no chaining, and it is something that we
can turn on in a mixed environment.
Tim Colson wrote:
>
> > Can you elaborate on why you feel that chaining the servlet scopes is
> > useful/necessary? The alternative I see is to just stick request, session
> > and application objects into the Velocity context.
>
> As I see it - chaining would be so Designers can chant $foo and
> VelStrutServletThingy would automagically chant $request.foo ->
> $session.foo -> $application.foo before giving up.
>
> I personally am afraid of exposing these objects _directly_ to Designers.
>
> I realize this makes it marginally harder to bridge the
> StrutsAction->VelServletOutput gap; however, I'd feel safer knowing that my
> Designer only has stuff I deemed 'safe' to give them.
>
> I feel safe to give them
> String foo = "bleck" -> $foo
> ...but worried giving them
> Request req -> $req.getSession().removeAttribute("foo");
>
> My twocents.
>
> Timo
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Struts/Velocity integration
Posted by Tim Colson <tc...@cisco.com>.
> Can you elaborate on why you feel that chaining the servlet scopes is
> useful/necessary? The alternative I see is to just stick request, session
> and application objects into the Velocity context.
As I see it - chaining would be so Designers can chant $foo and
VelStrutServletThingy would automagically chant $request.foo ->
$session.foo -> $application.foo before giving up.
I personally am afraid of exposing these objects _directly_ to Designers.
I realize this makes it marginally harder to bridge the
StrutsAction->VelServletOutput gap; however, I'd feel safer knowing that my
Designer only has stuff I deemed 'safe' to give them.
I feel safe to give them
String foo = "bleck" -> $foo
...but worried giving them
Request req -> $req.getSession().removeAttribute("foo");
My twocents.
Timo
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Gabriel Sidler <si...@teamup.ch>.
Ted Husted wrote:
[...]
> So, the other first step, along with Donnie's bean, I think, is to chain
> the request, session, and application contexts to a VelocityContext,
> behind a facade.
Ted,
you have mentioned in several of your posts the idea of chaining the
request, session and application scopes. I understand this such that
on lookup of a bean first the request scope is searched, then the
session scope is searched and finally the application scope is searched.
(Similar to what PageContext.findAttribute() does)
Can you elaborate on why you feel that chaining the servlet scopes is
useful/necessary? The alternative I see is to just stick request, session
and application objects into the Velocity context.
Gabe
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Ted Husted <hu...@apache.org>.
RequestUtils is JSP-centric since it was written to support the tag
extensions.
Any other apparent bias simply flows from the fact that right now, JSPs
is all Struts developers have at their disposal. But the framework
itself, is just tossing around JavaBeans and URIs, and things straight
out of the Servlet specification. There *is* a Servlet and JavaBean
bias, which I doubt would change anytime soon.
Meanwhile, If there were methods we could add to RequestUtils that would
benefit other presentation systems, then I'd be happy to commit them. I
do not consider JSPs to have any special status with the framework, they
are just want the initial volunteers were interested in doing.
The Struts resources themselves are first-order objects exposed in the
application scope, where anyone in the application can use them.
I believe that the original VelocityServlet idea is sound, and could
expose Velocity to any Web framework that uses the standard Servlet
contexts, including Struts.
A subclass of that might then provide access to the Struts specific
resources, like the MessageResources, ActionMappings, ActionForwards,
and ActionForms. That should be about it really.
MessageResouces - provides localised messages and labels.
ActionForward - provides a logical name for an URI, so it is not
embedded in the page.
ActionForms - a JavaBean "buffer" for HTML controls, with a hook for
automatic validation.
ActionMappings - a configuration object for a server-side Action. Most
often the target for a HTML form.
These are the framework specific objects, but developers are always
tossing in their own JavaBeans, and Vectors, and what-have-you, into the
servlet request or sessions contexts, in the same way the
VelocityContext is used (I imagine).
So, the other first step, along with Donnie's bean, I think, is to chain
the request, session, and application contexts to a VelocityContext,
behind a facade.
Konstantin Priblouda wrote:
>
> > Hm. If I recall, I did get it to work. The point
> > is not to reinvent the
> > wheel here, but integrate.
> >
> > It's been a while since I did this, but if I recall,
> > it's bean:message
> > because its using a regular bean that does the
> > actual message stuff.
>
> Hmm, I looked inside on sunday, and found that
> message getting stuff actually lives inside
> RequestUtils and isinfested with PageContext stuff
>
> ( mostly for generating stupid jsp exceptions in
> case property no existed while it would be enough
> to display property key instead )
>
> Struts is VERY jsp-centric...
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 8:05 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
>> Hm. If I recall, I did get it to work. The point
>> is not to reinvent the
>> wheel here, but integrate.
>>
>> It's been a while since I did this, but if I recall,
>> it's bean:message
>> because its using a regular bean that does the
>> actual message stuff.
>
> Hmm, I looked inside on sunday, and found that
> message getting stuff actually lives inside
> RequestUtils and isinfested with PageContext stuff
>
> ( mostly for generating stupid jsp exceptions in
> case property no existed while it would be enough
> to display property key instead )
>
> Struts is VERY jsp-centric...
Of course it's very JSP-centric...
There are two parts to <bean:message>, the
org.apache.struts.taglib.bean.MessageTag class, which is the JSP-centric
tag.
However, it fetches the message bundle via RequestUtils...
So much to do, so little time :)
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> Hm. If I recall, I did get it to work. The point
> is not to reinvent the
> wheel here, but integrate.
>
> It's been a while since I did this, but if I recall,
> it's bean:message
> because its using a regular bean that does the
> actual message stuff.
Hmm, I looked inside on sunday, and found that
message getting stuff actually lives inside
RequestUtils and isinfested with PageContext stuff
( mostly for generating stupid jsp exceptions in
case property no existed while it would be enough
to display property key instead )
Struts is VERY jsp-centric...
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/4/01 3:33 AM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
>
>>> - Implemented ( partially ) method message()
>>> to get functionality like <bean:message> -
>>> was really easy, most of code can be stolen
>>> from RequestUtils, with zapping all jspish
>>> stuff ( notably PageContext)
>>
>> The point is to bind it to strut's bean:message so
>> the message stuff can be
>> shared - you want to be able to make an app that
>> mixes both JSPs and vel
>> templates.
>
> I'm affraid that it's quite impossible. Because
> bean:message IS JSP tag (bean?) which relies heavily
> on PageContext being set
> ( an we are not going to reimplement JSP servlet :) )
>
Hm. If I recall, I did get it to work. The point is not to reinvent the
wheel here, but integrate.
It's been a while since I did this, but if I recall, it's bean:message
because its using a regular bean that does the actual message stuff.
So its just the JSP specific access (tag) that we can't use, but the core is
ok....
Again, it's been a while so I'll have to review.
> Good news is that it delegates most of the stuff
> to RequestUtils ( which is also very JSP specific ),
> but code can be sstolen from there
>
> regards,
>
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Velocity & Tomcat 4.0.1
Posted by Martin Stepanek <ab...@wo.cz>.
Thanks for advices, it needed some more experimenting. I needed to use
relative paths and modify correctly the web.xml (properties param value) as
well as velocity.properties. Now it works fine.
> Try putting in into the WEB-INF/classes directory of your web-application
> directory. That should do the trick.
No, it really wasn't necessary. I found it is possible to place it anywhere
in the webapp directory and subdirectories with the help of properies
parameter in the web.xml. :o)
> /examples directory - see how the init() stuff works - you want
> to specify
> your properties file relative to the context root, and use
> getRealPath() to
> get the full path.
Yes, it gave me some insight into the problem after putting some
System.out.println(blahblah) stuff in this part of code :o)
Best regards
Martin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Velocity & Tomcat 4.0.1
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/20/01 8:18 AM, "Martin Stepanek" <ab...@wo.cz> wrote:
> Hi all,
>
> has anyone some experience with Velocity and Tomcat 4.0.1? I tried to get
> work the servlet examples, but my Velocity can't locate the templates. I
> have a suspicion, the Tomcat can't locate the Velocity.properties file and
> as a result the Velocity can't find the templates directory. I had similar
> problem with Webmacro, but I finally resolved it by placing the
> Webmacro.properties into the WEB-INF/classes directory, but with Velocity
> this doesn't help...
What do you put in the web.xml to tell VelocityServlet where to find it?
>
> I already tried to put the Velocity.properties to many locations in the
> webapps directory and subdirectories and tried to set the
> file.resource.loader.path property to relative as well as complete path to
> the template directory, but nothing worked...
Note that unlike WebMacro, VelocityServlet doesn't flail about looking for
the properties file automatically, but requires you to specify it.
> I only can get the template if I put it in the Tomcats bin directory, but
> this surely isn't the way to go :o)
>
No - I understand the problem... Look at the servlet2 example in the
/examples directory - see how the init() stuff works - you want to specify
your properties file relative to the context root, and use getRealPath() to
get the full path.
I have an update to VelocityServlet that changes this because this won't
work with WebLogic or other containers that don't unwind the WARs, so we'll
get rid of getRealPath(). I can check that in today.
I also have a new loader to contribute that I put together for the new
struts support servlet stuff (that will be hopefully later today when we
talk about ToolLand), but need to solidify something with application
context before doing that.
In short, look at the example.
> Please, can you give me some sugestion, what could be wrong?
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Be a giant. Take giant steps. Do giant things...
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Velocity & Tomcat 4.0.1
Posted by Martin Stepanek <ab...@wo.cz>.
Hi all,
has anyone some experience with Velocity and Tomcat 4.0.1? I tried to get
work the servlet examples, but my Velocity can't locate the templates. I
have a suspicion, the Tomcat can't locate the Velocity.properties file and
as a result the Velocity can't find the templates directory. I had similar
problem with Webmacro, but I finally resolved it by placing the
Webmacro.properties into the WEB-INF/classes directory, but with Velocity
this doesn't help...
I already tried to put the Velocity.properties to many locations in the
webapps directory and subdirectories and tried to set the
file.resource.loader.path property to relative as well as complete path to
the template directory, but nothing worked...
I only can get the template if I put it in the Tomcats bin directory, but
this surely isn't the way to go :o)
Please, can you give me some sugestion, what could be wrong?
Thanx
Martin
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by Konstantin Priblouda <kp...@yahoo.com>.
> > - Implemented ( partially ) method message()
> > to get functionality like <bean:message> -
> > was really easy, most of code can be stolen
> > from RequestUtils, with zapping all jspish
> > stuff ( notably PageContext)
>
> The point is to bind it to strut's bean:message so
> the message stuff can be
> shared - you want to be able to make an app that
> mixes both JSPs and vel
> templates.
I'm affraid that it's quite impossible. Because
bean:message IS JSP tag (bean?) which relies heavily
on PageContext being set
( an we are not going to reimplement JSP servlet :) )
Good news is that it delegates most of the stuff
to RequestUtils ( which is also very JSP specific ),
but code can be sstolen from there
regards,
=====
Konstantin Priblouda ( ko5tik ) Freelance Software developer
< http://www.pribluda.de > < play java games -> http://www.yook.de >
< render charts online -> http://www.pribluda.de/povray/ >
__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Struts/Velocity integration
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/2/01 2:04 PM, "Konstantin Priblouda" <kp...@yahoo.com> wrote:
> Well, there was a lot of discussion about it.
>
> What about to start doing something? :)
I did something a while ago... There is a struts-velocity toy proof of
concept in contrib/temporary/struts-velocity
>
> I played around today:
>
> - Subclassed velocity servlet and added
> "StrutsUtil" object to context.
>
> - Implemented ( partially ) method message()
> to get functionality like <bean:message> -
> was really easy, most of code can be stolen
> from RequestUtils, with zapping all jspish
> stuff ( notably PageContext)
The point is to bind it to strut's bean:message so the message stuff can be
shared - you want to be able to make an app that mixes both JSPs and vel
templates.
>
> It worked perfectly ( and was easy )
>
> anybody to join me?
>
> regards,
>
> =====
> Konstantin Priblouda ( ko5tik ) Freelance Software developer
> < http://www.pribluda.de > < play java games -> http://www.yook.de >
> < render charts online -> http://www.pribluda.de/povray/ >
>
> __________________________________________________
> Do You Yahoo!?
> Buy the perfect holiday gifts at Yahoo! Shopping.
> http://shopping.yahoo.com
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>