You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Shawn Church <sh...@boxity.com> on 2002/03/04 18:35:01 UTC

ContextTool

I have used WebMacro extensively over the past couple of years, but I am
also curious about Velocity.  It seems to work pretty much as expected, but
I haven't noticed an equivalent interface in Velocity to the WebMacro
ContextTool.  Does anything like this exist in Velocity?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ContextTool

Posted by Jonathan Carlson <jo...@yahoo.com>.
Another MVC-2 implementation that I am very pleased with is 
ActionServlet.  It is documented well, has lots of example code, 
supports "pull" tools (called Components), and even allows you to 
specify/change the flow of control in an XML descriptor file.  It does 
what it does very well without trying to include "everything but the 
kitchen sink".

http://dione.zcu.cz/~toman40/ActionServlet/

Jonathan

-- 
Jonathan Carlson
joncrlsn@users.sf.net
Minneapolis, Minnesota



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ContextTool

Posted by Bill Burton <bi...@progress.com>.
Hello,

Sounds like what you're looking for is some kind of "pull" tool.  The
Turbine framework supports this methodology which you can read about at
http://jakarta.apache.org/turbine/turbine-2/pullmodel.html.  You could
also roll your own pull tool to do something similar.  Create a class with
a "get" method that takes the name of the class (or an alias) that you
want to load.  When the get method in your tool class is called, it would
instantiate the desired class if that had not already been done for the
request and then return the reference to it.   Assuming the tool helper
class was put into the context as "tool", you'd access your class like:
    $tool.myclass...

You could associate the name "myclass" to be used as the context name with
the class name in velocity.properties or by other similar means.

The WebWork framework (http://sourceforge.net/projects/webwork/) supports
a similar but Model-1 type approach.  The #bean macro can be used to
instantiate any class with a public null contstructor. Or, the #action
macro will instantiate a class that implements the WebWork Action
interface.  In both cases, you may need to call the #execute macro to
execute some logic.  WebWork isn't quite released as 1.0, so if you're
interested it would be best to pull it from CVS.

Struts, Turbine, WebWork and other frameworks all support the Model-2
(MVC) approach where requests are directed to a controller servlet that
delegates to some Action class to execute some business logic.  From there
the request is usually forwarded to the template.  However, these Action
type classes tend to be used for business logic as opposed to simple
helper functions.  

-Bill

Shawn Church wrote:
> 
> That's essentially what I'm looking for, as long as the tool is instantiated
> only on its first use.  I have read over the Velocity developer's guide, but
> I may not have noticed the implementation.  So far, I have been explicitly
> loading these tool classes into the context on each request.  However, not
> every page will necessarily make use of these tools, so the instantiation is
> wasted in these cases.
> 
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Monday, March 04, 2002 12:07 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: ContextTool
> 
> On 3/4/02 12:35 PM, "Shawn Church" <sh...@boxity.com> wrote:
> 
> > I have used WebMacro extensively over the past couple of years, but I am
> > also curious about Velocity.  It seems to work pretty much as expected,
> but
> > I haven't noticed an equivalent interface in Velocity to the WebMacro
> > ContextTool.  Does anything like this exist in Velocity?
> >
> 
> Do you mean autoloading of tool classes in the context?
> 
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
> 
> Age and treachery will always triumph over youth and talent
> 
> --
> 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: ContextTool

Posted by Shawn Church <sh...@boxity.com>.
That's essentially what I'm looking for, as long as the tool is instantiated
only on its first use.  I have read over the Velocity developer's guide, but
I may not have noticed the implementation.  So far, I have been explicitly
loading these tool classes into the context on each request.  However, not
every page will necessarily make use of these tools, so the instantiation is
wasted in these cases.

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Monday, March 04, 2002 12:07 PM
To: velocity-user@jakarta.apache.org
Subject: Re: ContextTool


On 3/4/02 12:35 PM, "Shawn Church" <sh...@boxity.com> wrote:

> I have used WebMacro extensively over the past couple of years, but I am
> also curious about Velocity.  It seems to work pretty much as expected,
but
> I haven't noticed an equivalent interface in Velocity to the WebMacro
> ContextTool.  Does anything like this exist in Velocity?
>

Do you mean autoloading of tool classes in the context?

--
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting

Age and treachery will always triumph over youth and talent


--
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: ContextTool

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 3/4/02 12:35 PM, "Shawn Church" <sh...@boxity.com> wrote:

> I have used WebMacro extensively over the past couple of years, but I am
> also curious about Velocity.  It seems to work pretty much as expected, but
> I haven't noticed an equivalent interface in Velocity to the WebMacro
> ContextTool.  Does anything like this exist in Velocity?
> 

Do you mean autoloading of tool classes in the context?

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting

Age and treachery will always triumph over youth and talent


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>