You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Glenn Holmer <gh...@weycogroup.com> on 2008/04/01 17:49:48 UTC
upgrading
I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
any gotchas I should watch out for?
--
____________________________________________________________
Glenn Holmer gholmer@weycogroup.com
Software Engineer phone: 414-908-1809
Weyco Group, Inc. fax: 414-908-1601
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
no, i mean like:
#macro( foo )#*
*#this macro has issue :(#*
*##end
see https://issues.apache.org/jira/browse/VELOCITY-537 for more info
On Tue, Apr 1, 2008 at 10:46 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
> Nathan Bubna wrote:
> > there are some issues with multi-line comments within macros in
> > Velocity 1.5
>
> You mean like this?
>
> #**
> * Show messages with the given property using CSS class "info".
> * @param property The property of messages to show.
> *#
>
>
> > that's all i can think of right now, but of course, feel free to ask
> > questions/report problems here.
>
> Thanks, I'll post if we get stuck.
>
> --
>
>
> ____________________________________________________________
> Glenn Holmer gholmer@weycogroup.com
> Software Engineer phone: 414-908-1809
> Weyco Group, Inc. fax: 414-908-1601
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Glenn Holmer <gh...@weycogroup.com>.
Nathan Bubna wrote:
> there are some issues with multi-line comments within macros in
> Velocity 1.5
You mean like this?
#**
* Show messages with the given property using CSS class "info".
* @param property The property of messages to show.
*#
> that's all i can think of right now, but of course, feel free to ask
> questions/report problems here.
Thanks, I'll post if we get stuck.
--
____________________________________________________________
Glenn Holmer gholmer@weycogroup.com
Software Engineer phone: 414-908-1809
Weyco Group, Inc. fax: 414-908-1601
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Claude Brisson <cl...@renegat.net>.
Le mardi 01 avril 2008 à 17:26 -0400, Charles Harvey III a écrit :
> Nathan,
> Thanks for all that info. It will definitely be a big help. The
> biggest issue
> I have is that I am still stuck on tools-1.2. So I still have to go through
> the pain of removing the "implements ViewTool" from all of my tools before I
> drop in anything new. I think after that it should be fairly
> straightforward.
>
> The only thing I didn't get was how the standard VelocityTools are available
> without any configuration. That just happens when I setup
> VelocityLayoutServlet
> in web.xml and pass it the org.apache.velocity.toolbox param?
It should not even be necessary to give it this parameter if you name it
"/WEB-INF/toolbox.xml" (old name) or "/WEB-INF/tools.xml" (new name).
Please note that the format of the new file has slightly changed. See
http://velocity.apache.org/tools/devel/config.xml.html .
Claude
> Thanks again.
>
>
> Charlie
>
>
> Nathan Bubna said the following on 4/1/2008 5:03 PM:
> > sadly, no. no one has written such a document yet. but here's a
> > sketch outline:
> >
> > first, just drop in the Tools 2 jar as a straight up replacement.
> > assuming your app already worked great with Tools 1.3+, it should just
> > work. if not, let us know. we're trying to be fully backwards
> > compatible (though we did drop some stuff that's was deprecated in
> > 1.3).
> >
> > when you run that, look for any upgrade/deprecation notices in the
> > logs. that might help give details for the rest. (not sure on that
> > though)
> >
> > next, try adjusting to the new package locations for things like the
> > VelocityViewServlet and VelocityLayoutServlet. Quick guide would be
> > that things in org.apache.velocity.tools.view.servlet and
> > org.apache.velocity.tools.view.context are now just in
> > org.apache.velocity.tools.view.
> >
> > if you specifically reference the o.a.v.t.view.servlet.WebappLoader,
> > it is now the o.a.v.t.view.WebappResourceLoader.
> >
> > now, since Tools 2 does lazy loading of tools, it now costs very
> > little per-request to have a lot of tools available. so, unless the
> > user is doing something to trigger the "deprecation support mode" for
> > VelocityView (using the old xml format would trigger this), all of the
> > standard VelocityTools will be automatically made available by
> > default. so, if you don't custom configure any of the provided tools
> > and don't have any custom tools of your own, then you don't actually
> > need a configuration.
> >
> > if you do need a configuration, try switching your configuration to
> > the new format. easiest would be to go from the old xml format to the
> > new xml format:
> > http://velocity.apache.org/tools/devel/config.xml.html
> > remember, you can just leave out standard tools that you don't do any
> > configuration of.
> >
> > if you do configure some of the standard tools, then while you are
> > updating the configuration format, you might also check to see if that
> > tool has been moved to a new package. the easiest way is probably
> > just to check in the javadoc. tools which are deprecated should tell
> > you what their replacement is. a few tools also had name changes
> > (e.g. ParameterParser to ParameterTool and BrowserSniffer to
> > BrowserTool)
> >
> > that should cover most everything, except how to upgrade your custom
> > tools to do things the Tools 2 way. here's a few quick starts for
> > that, though this doesn't cover everything:
> >
> > the recommended practice is to give a tool to be used as $foo the name
> > FooTool. not required, but it makes things easier for people to
> > follow and learn. if you are going name a tool FooBarUtility but want
> > it to be $foo in the context, the second best thing is to provide a
> > @DefaultKey("foo") annotation on the class.
> >
> > also, if your tool is only meant to be used in a particular scope,
> > it's recommended that you give the class a @ValidScope(Scope.REQUEST)
> > annotation as well. if you only want to ban a particular scope and
> > allow all others, you could provide a @InvalidScope(Scope.APPLICATION)
> > annotation on the class. the Scope class provides constants for
> > REQUEST, SESSION, and APPLICATION. i believe other scopes are now
> > theoretically possible, but only a little work and less testing has
> > been done there.
> >
> > if you have a configurable tool whose configuration should not changed
> > by the templates which use it, then consider having your tool extend
> > the AbstractLockConfig class (or one of its kin FormatConfig or
> > LocaleConfig). if you want to know more about these, let me know.
> >
> > in general, the configure(Map) and init(Object) methods have been
> > changed into just the configure(Map) and individual setter methods
> > (e.g. setRequest, setSession, etc). basically, when it's time to
> > instantiate a tool, the tool manager will gather all the configuration
> > properties for that tool, its toolbox, etc and combine it into a
> > single map with the init data (context, request, session, etc). the
> > manager searches for relevant setter methods that accept that data and
> > also for a configure(Map) method. the setters get what they're asking
> > for (if available) and the configure method accepts the whole combined
> > Map. the upshot of this approach is that tools no longer need to
> > conform to any interfaces or patterns. in fact, it's possible to
> > write a FooTool that doesn't know anything about any VelocityTools
> > classes whatsoever and yet be fully instantiable and configurable by
> > VelocityTools. your tools don't need to know about anything except
> > what they need to know about.
> >
> > and that all turned out longer than planned. i guess i have the start
> > of a migration document now, eh? let me know how it works out for
> > you.
> >
> > On Tue, Apr 1, 2008 at 12:32 PM, Charles Harvey III <ch...@alloy.com> wrote:
> >
> >> I would like to start migrating my tools to the 2.0 path. Is there a
> >> good document
> >> on the site that tells me how to do do? I have been looking and I'm not
> >> sure if I
> >> am looking in the right places.
> >>
> >> Thanks.
> >>
> >>
> >> Charlie
> >>
> >>
> >> Nathan Bubna said the following on 4/1/2008 3:16 PM:
> >>
> >>
> >>
> >>> yep, that's the idea. as for the init() method, you only need it if
> >>>
> >> > your tool needs access to the initData for that scope (ServletContext
> >> > for application scope and ViewContext for request or session scope).
> >> > if your tool doesn't need access to any of those things, then it
> >> > doesn't need an init(Object) method.
> >> >
> >> > of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
> >> > things get even easier. :)
> >> >
> >> > On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com> wrote:
> >> >
> >> >> As far as your own tools goes, I want to make sure I've got it right:
> >> >>
> >> >> Old:
> >> >> -------------------------------------------------------------
> >> >> public class MyTool implements ViewTool
> >> >> {
> >> >> private String theString;
> >> >>
> >> >> public void init( Object o )
> >> >> {
> >> >> if( !( obj instanceof ViewContext ) )
> >> >> {
> >> >> throw new IllegalArgumentException( "Tool can only be
> >> >> initialized with a ViewContext" );
> >> >> }
> >> >> }
> >> >>
> >> >> public String getTheString()
> >> >> {
> >> >> return "this string comes from a velocity tool";
> >> >> }
> >> >> }
> >> >> -------------------------------------------------------------
> >> >>
> >> >>
> >> >> New:
> >> >> -------------------------------------------------------------
> >> >> public class MyTool
> >> >> {
> >> >> private String theString;
> >> >>
> >> >> public void init( Object o )
> >> >> {
> >> >> if( !( obj instanceof ViewContext ) )
> >> >> {
> >> >> throw new IllegalArgumentException( "Tool can only be
> >> >> initialized with a ViewContext" );
> >> >> }
> >> >> }
> >> >>
> >> >> public String getTheString()
> >> >> {
> >> >> return "this string comes from a velocity tool";
> >> >> }
> >> >> }
> >> >> -------------------------------------------------------------
> >> >>
> >> >>
> >> >> Do I still need the init method? Or can I skip that too?
> >> >>
> >> >> Thanks.
> >> >>
> >> >>
> >> >> Charlie
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Nathan Bubna said the following on 4/1/2008 1:06 PM:
> >> >>
> >> >>
> >> >>
> >> >>> there are some issues with multi-line comments within macros in Velocity 1.5
> >> >>>
> >> >> >
> >> >> > if you have written your own custom tools, then you'll find the
> >> >> > ViewTool and Configurable interfaces have been axed in VelocityTools
> >> >> > 1.4. just remove the implements declarations for those interfaces.
> >> >> > they are unnecessary, as Tools 1.4 will automatically look for their
> >> >> > methods in any tool class. if you haven't written any tools of your
> >> >> > own, i don't think there's anything to be concerned about.
> >> >> >
> >> >> > that's all i can think of right now, but of course, feel free to ask
> >> >> > questions/report problems here.
> >> >> >
> >> >> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
> >> >> >
> >> >> >> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
> >> >> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
> >> >> >> any gotchas I should watch out for?
> >> >> >>
> >> >> >> --
> >> >> >> ____________________________________________________________
> >> >> >> Glenn Holmer gholmer@weycogroup.com
> >> >> >> Software Engineer phone: 414-908-1809
> >> >> >> Weyco Group, Inc. fax: 414-908-1601
> >> >> >>
> >> >> >>
> >> >> >> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> >> >> For additional commands, e-mail: user-help@velocity.apache.org
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >
> >> >> > ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> >> > For additional commands, e-mail: user-help@velocity.apache.org
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> >> For additional commands, e-mail: user-help@velocity.apache.org
> >> >>
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> > For additional commands, e-mail: user-help@velocity.apache.org
> >> >
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: user-help@velocity.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
On Tue, Apr 1, 2008 at 2:26 PM, Charles Harvey III <ch...@alloy.com> wrote:
> Nathan,
> Thanks for all that info. It will definitely be a big help. The
> biggest issue
> I have is that I am still stuck on tools-1.2. So I still have to go through
> the pain of removing the "implements ViewTool" from all of my tools before I
> drop in anything new. I think after that it should be fairly
> straightforward.
>
> The only thing I didn't get was how the standard VelocityTools are available
> without any configuration. That just happens when I setup
> VelocityLayoutServlet
> in web.xml and pass it the org.apache.velocity.toolbox param?
Tools 2 comes with a default tools.xml file each for GenericTools,
VelocityView and VelocityStruts, and the VelocityViewServlet (and
friends) will automatically look for and load those unless you
explicitly tell it not to or are using a deprecated toolbox.xml.
you can explicitly turn this off by adding the init-param
org.apache.velocity.tools.loadDefaults with the value of false.
overriding these default settings is as simple as providing your own
config for those tools. tool configurations are key-centric. if you
just want to provide a different default format for the DateTool, your
tools.xml can be just:
<tools>
<toolbox scope="application">
<tool key="date" format="MM/dd/yy"/>
</toolbox>
</tools>
this just overrides the format property for the "date" tool in the
configuration. since "date" already has a class set in the default
tools.xml that comes with the GenericTools package, you don't need to
include that.
> Thanks again.
>
>
> Charlie
>
>
> Nathan Bubna said the following on 4/1/2008 5:03 PM:
>
>
> > sadly, no. no one has written such a document yet. but here's a
> > sketch outline:
> >
> > first, just drop in the Tools 2 jar as a straight up replacement.
> > assuming your app already worked great with Tools 1.3+, it should just
> > work. if not, let us know. we're trying to be fully backwards
> > compatible (though we did drop some stuff that's was deprecated in
> > 1.3).
> >
> > when you run that, look for any upgrade/deprecation notices in the
> > logs. that might help give details for the rest. (not sure on that
> > though)
> >
> > next, try adjusting to the new package locations for things like the
> > VelocityViewServlet and VelocityLayoutServlet. Quick guide would be
> > that things in org.apache.velocity.tools.view.servlet and
> > org.apache.velocity.tools.view.context are now just in
> > org.apache.velocity.tools.view.
> >
> > if you specifically reference the o.a.v.t.view.servlet.WebappLoader,
> > it is now the o.a.v.t.view.WebappResourceLoader.
> >
> > now, since Tools 2 does lazy loading of tools, it now costs very
> > little per-request to have a lot of tools available. so, unless the
> > user is doing something to trigger the "deprecation support mode" for
> > VelocityView (using the old xml format would trigger this), all of the
> > standard VelocityTools will be automatically made available by
> > default. so, if you don't custom configure any of the provided tools
> > and don't have any custom tools of your own, then you don't actually
> > need a configuration.
> >
> > if you do need a configuration, try switching your configuration to
> > the new format. easiest would be to go from the old xml format to the
> > new xml format:
> > http://velocity.apache.org/tools/devel/config.xml.html
> > remember, you can just leave out standard tools that you don't do any
> > configuration of.
> >
> > if you do configure some of the standard tools, then while you are
> > updating the configuration format, you might also check to see if that
> > tool has been moved to a new package. the easiest way is probably
> > just to check in the javadoc. tools which are deprecated should tell
> > you what their replacement is. a few tools also had name changes
> > (e.g. ParameterParser to ParameterTool and BrowserSniffer to
> > BrowserTool)
> >
> > that should cover most everything, except how to upgrade your custom
> > tools to do things the Tools 2 way. here's a few quick starts for
> > that, though this doesn't cover everything:
> >
> > the recommended practice is to give a tool to be used as $foo the name
> > FooTool. not required, but it makes things easier for people to
> > follow and learn. if you are going name a tool FooBarUtility but want
> > it to be $foo in the context, the second best thing is to provide a
> > @DefaultKey("foo") annotation on the class.
> >
> > also, if your tool is only meant to be used in a particular scope,
> > it's recommended that you give the class a @ValidScope(Scope.REQUEST)
> > annotation as well. if you only want to ban a particular scope and
> > allow all others, you could provide a @InvalidScope(Scope.APPLICATION)
> > annotation on the class. the Scope class provides constants for
> > REQUEST, SESSION, and APPLICATION. i believe other scopes are now
> > theoretically possible, but only a little work and less testing has
> > been done there.
> >
> > if you have a configurable tool whose configuration should not changed
> > by the templates which use it, then consider having your tool extend
> > the AbstractLockConfig class (or one of its kin FormatConfig or
> > LocaleConfig). if you want to know more about these, let me know.
> >
> > in general, the configure(Map) and init(Object) methods have been
> > changed into just the configure(Map) and individual setter methods
> > (e.g. setRequest, setSession, etc). basically, when it's time to
> > instantiate a tool, the tool manager will gather all the configuration
> > properties for that tool, its toolbox, etc and combine it into a
> > single map with the init data (context, request, session, etc). the
> > manager searches for relevant setter methods that accept that data and
> > also for a configure(Map) method. the setters get what they're asking
> > for (if available) and the configure method accepts the whole combined
> > Map. the upshot of this approach is that tools no longer need to
> > conform to any interfaces or patterns. in fact, it's possible to
> > write a FooTool that doesn't know anything about any VelocityTools
> > classes whatsoever and yet be fully instantiable and configurable by
> > VelocityTools. your tools don't need to know about anything except
> > what they need to know about.
> >
> > and that all turned out longer than planned. i guess i have the start
> > of a migration document now, eh? let me know how it works out for
> > you.
> >
> > On Tue, Apr 1, 2008 at 12:32 PM, Charles Harvey III <ch...@alloy.com> wrote:
> >
> >> I would like to start migrating my tools to the 2.0 path. Is there a
> >> good document
> >> on the site that tells me how to do do? I have been looking and I'm not
> >> sure if I
> >> am looking in the right places.
> >>
> >> Thanks.
> >>
> >>
> >> Charlie
> >>
> >>
> >> Nathan Bubna said the following on 4/1/2008 3:16 PM:
> >>
> >>
> >>
> >>> yep, that's the idea. as for the init() method, you only need it if
> >>>
> >> > your tool needs access to the initData for that scope (ServletContext
> >> > for application scope and ViewContext for request or session scope).
> >> > if your tool doesn't need access to any of those things, then it
> >> > doesn't need an init(Object) method.
> >> >
> >> > of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
> >> > things get even easier. :)
> >> >
> >> > On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com> wrote:
> >> >
> >> >> As far as your own tools goes, I want to make sure I've got it right:
> >> >>
> >> >> Old:
> >> >> -------------------------------------------------------------
> >> >> public class MyTool implements ViewTool
> >> >> {
> >> >> private String theString;
> >> >>
> >> >> public void init( Object o )
> >> >> {
> >> >> if( !( obj instanceof ViewContext ) )
> >> >> {
> >> >> throw new IllegalArgumentException( "Tool can only be
> >> >> initialized with a ViewContext" );
> >> >> }
> >> >> }
> >> >>
> >> >> public String getTheString()
> >> >> {
> >> >> return "this string comes from a velocity tool";
> >> >> }
> >> >> }
> >> >> -------------------------------------------------------------
> >> >>
> >> >>
> >> >> New:
> >> >> -------------------------------------------------------------
> >> >> public class MyTool
> >> >> {
> >> >> private String theString;
> >> >>
> >> >> public void init( Object o )
> >> >> {
> >> >> if( !( obj instanceof ViewContext ) )
> >> >> {
> >> >> throw new IllegalArgumentException( "Tool can only be
> >> >> initialized with a ViewContext" );
> >> >> }
> >> >> }
> >> >>
> >> >> public String getTheString()
> >> >> {
> >> >> return "this string comes from a velocity tool";
> >> >> }
> >> >> }
> >> >> -------------------------------------------------------------
> >> >>
> >> >>
> >> >> Do I still need the init method? Or can I skip that too?
> >> >>
> >> >> Thanks.
> >> >>
> >> >>
> >> >> Charlie
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Nathan Bubna said the following on 4/1/2008 1:06 PM:
> >> >>
> >> >>
> >> >>
> >> >>> there are some issues with multi-line comments within macros in Velocity 1.5
> >> >>>
> >> >> >
> >> >> > if you have written your own custom tools, then you'll find the
> >> >> > ViewTool and Configurable interfaces have been axed in VelocityTools
> >> >> > 1.4. just remove the implements declarations for those interfaces.
> >> >> > they are unnecessary, as Tools 1.4 will automatically look for their
> >> >> > methods in any tool class. if you haven't written any tools of your
> >> >> > own, i don't think there's anything to be concerned about.
> >> >> >
> >> >> > that's all i can think of right now, but of course, feel free to ask
> >> >> > questions/report problems here.
> >> >> >
> >> >> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
> >> >> >
> >> >> >> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
> >> >> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
> >> >> >> any gotchas I should watch out for?
> >> >> >>
> >> >> >> --
> >> >> >> ____________________________________________________________
> >> >> >> Glenn Holmer gholmer@weycogroup.com
> >> >> >> Software Engineer phone: 414-908-1809
> >> >> >> Weyco Group, Inc. fax: 414-908-1601
> >> >> >>
> >> >> >>
> >> >> >> ---------------------------------------------------------------------
> >> >> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> >> >> For additional commands, e-mail: user-help@velocity.apache.org
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >
> >> >> > ---------------------------------------------------------------------
> >> >> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> >> > For additional commands, e-mail: user-help@velocity.apache.org
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> >> For additional commands, e-mail: user-help@velocity.apache.org
> >> >>
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> > For additional commands, e-mail: user-help@velocity.apache.org
> >> >
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: user-help@velocity.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
Nathan,
Thanks for all that info. It will definitely be a big help. The
biggest issue
I have is that I am still stuck on tools-1.2. So I still have to go through
the pain of removing the "implements ViewTool" from all of my tools before I
drop in anything new. I think after that it should be fairly
straightforward.
The only thing I didn't get was how the standard VelocityTools are available
without any configuration. That just happens when I setup
VelocityLayoutServlet
in web.xml and pass it the org.apache.velocity.toolbox param?
Thanks again.
Charlie
Nathan Bubna said the following on 4/1/2008 5:03 PM:
> sadly, no. no one has written such a document yet. but here's a
> sketch outline:
>
> first, just drop in the Tools 2 jar as a straight up replacement.
> assuming your app already worked great with Tools 1.3+, it should just
> work. if not, let us know. we're trying to be fully backwards
> compatible (though we did drop some stuff that's was deprecated in
> 1.3).
>
> when you run that, look for any upgrade/deprecation notices in the
> logs. that might help give details for the rest. (not sure on that
> though)
>
> next, try adjusting to the new package locations for things like the
> VelocityViewServlet and VelocityLayoutServlet. Quick guide would be
> that things in org.apache.velocity.tools.view.servlet and
> org.apache.velocity.tools.view.context are now just in
> org.apache.velocity.tools.view.
>
> if you specifically reference the o.a.v.t.view.servlet.WebappLoader,
> it is now the o.a.v.t.view.WebappResourceLoader.
>
> now, since Tools 2 does lazy loading of tools, it now costs very
> little per-request to have a lot of tools available. so, unless the
> user is doing something to trigger the "deprecation support mode" for
> VelocityView (using the old xml format would trigger this), all of the
> standard VelocityTools will be automatically made available by
> default. so, if you don't custom configure any of the provided tools
> and don't have any custom tools of your own, then you don't actually
> need a configuration.
>
> if you do need a configuration, try switching your configuration to
> the new format. easiest would be to go from the old xml format to the
> new xml format:
> http://velocity.apache.org/tools/devel/config.xml.html
> remember, you can just leave out standard tools that you don't do any
> configuration of.
>
> if you do configure some of the standard tools, then while you are
> updating the configuration format, you might also check to see if that
> tool has been moved to a new package. the easiest way is probably
> just to check in the javadoc. tools which are deprecated should tell
> you what their replacement is. a few tools also had name changes
> (e.g. ParameterParser to ParameterTool and BrowserSniffer to
> BrowserTool)
>
> that should cover most everything, except how to upgrade your custom
> tools to do things the Tools 2 way. here's a few quick starts for
> that, though this doesn't cover everything:
>
> the recommended practice is to give a tool to be used as $foo the name
> FooTool. not required, but it makes things easier for people to
> follow and learn. if you are going name a tool FooBarUtility but want
> it to be $foo in the context, the second best thing is to provide a
> @DefaultKey("foo") annotation on the class.
>
> also, if your tool is only meant to be used in a particular scope,
> it's recommended that you give the class a @ValidScope(Scope.REQUEST)
> annotation as well. if you only want to ban a particular scope and
> allow all others, you could provide a @InvalidScope(Scope.APPLICATION)
> annotation on the class. the Scope class provides constants for
> REQUEST, SESSION, and APPLICATION. i believe other scopes are now
> theoretically possible, but only a little work and less testing has
> been done there.
>
> if you have a configurable tool whose configuration should not changed
> by the templates which use it, then consider having your tool extend
> the AbstractLockConfig class (or one of its kin FormatConfig or
> LocaleConfig). if you want to know more about these, let me know.
>
> in general, the configure(Map) and init(Object) methods have been
> changed into just the configure(Map) and individual setter methods
> (e.g. setRequest, setSession, etc). basically, when it's time to
> instantiate a tool, the tool manager will gather all the configuration
> properties for that tool, its toolbox, etc and combine it into a
> single map with the init data (context, request, session, etc). the
> manager searches for relevant setter methods that accept that data and
> also for a configure(Map) method. the setters get what they're asking
> for (if available) and the configure method accepts the whole combined
> Map. the upshot of this approach is that tools no longer need to
> conform to any interfaces or patterns. in fact, it's possible to
> write a FooTool that doesn't know anything about any VelocityTools
> classes whatsoever and yet be fully instantiable and configurable by
> VelocityTools. your tools don't need to know about anything except
> what they need to know about.
>
> and that all turned out longer than planned. i guess i have the start
> of a migration document now, eh? let me know how it works out for
> you.
>
> On Tue, Apr 1, 2008 at 12:32 PM, Charles Harvey III <ch...@alloy.com> wrote:
>
>> I would like to start migrating my tools to the 2.0 path. Is there a
>> good document
>> on the site that tells me how to do do? I have been looking and I'm not
>> sure if I
>> am looking in the right places.
>>
>> Thanks.
>>
>>
>> Charlie
>>
>>
>> Nathan Bubna said the following on 4/1/2008 3:16 PM:
>>
>>
>>
>>> yep, that's the idea. as for the init() method, you only need it if
>>>
>> > your tool needs access to the initData for that scope (ServletContext
>> > for application scope and ViewContext for request or session scope).
>> > if your tool doesn't need access to any of those things, then it
>> > doesn't need an init(Object) method.
>> >
>> > of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
>> > things get even easier. :)
>> >
>> > On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com> wrote:
>> >
>> >> As far as your own tools goes, I want to make sure I've got it right:
>> >>
>> >> Old:
>> >> -------------------------------------------------------------
>> >> public class MyTool implements ViewTool
>> >> {
>> >> private String theString;
>> >>
>> >> public void init( Object o )
>> >> {
>> >> if( !( obj instanceof ViewContext ) )
>> >> {
>> >> throw new IllegalArgumentException( "Tool can only be
>> >> initialized with a ViewContext" );
>> >> }
>> >> }
>> >>
>> >> public String getTheString()
>> >> {
>> >> return "this string comes from a velocity tool";
>> >> }
>> >> }
>> >> -------------------------------------------------------------
>> >>
>> >>
>> >> New:
>> >> -------------------------------------------------------------
>> >> public class MyTool
>> >> {
>> >> private String theString;
>> >>
>> >> public void init( Object o )
>> >> {
>> >> if( !( obj instanceof ViewContext ) )
>> >> {
>> >> throw new IllegalArgumentException( "Tool can only be
>> >> initialized with a ViewContext" );
>> >> }
>> >> }
>> >>
>> >> public String getTheString()
>> >> {
>> >> return "this string comes from a velocity tool";
>> >> }
>> >> }
>> >> -------------------------------------------------------------
>> >>
>> >>
>> >> Do I still need the init method? Or can I skip that too?
>> >>
>> >> Thanks.
>> >>
>> >>
>> >> Charlie
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Nathan Bubna said the following on 4/1/2008 1:06 PM:
>> >>
>> >>
>> >>
>> >>> there are some issues with multi-line comments within macros in Velocity 1.5
>> >>>
>> >> >
>> >> > if you have written your own custom tools, then you'll find the
>> >> > ViewTool and Configurable interfaces have been axed in VelocityTools
>> >> > 1.4. just remove the implements declarations for those interfaces.
>> >> > they are unnecessary, as Tools 1.4 will automatically look for their
>> >> > methods in any tool class. if you haven't written any tools of your
>> >> > own, i don't think there's anything to be concerned about.
>> >> >
>> >> > that's all i can think of right now, but of course, feel free to ask
>> >> > questions/report problems here.
>> >> >
>> >> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
>> >> >
>> >> >> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
>> >> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
>> >> >> any gotchas I should watch out for?
>> >> >>
>> >> >> --
>> >> >> ____________________________________________________________
>> >> >> Glenn Holmer gholmer@weycogroup.com
>> >> >> Software Engineer phone: 414-908-1809
>> >> >> Weyco Group, Inc. fax: 414-908-1601
>> >> >>
>> >> >>
>> >> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> >> >> For additional commands, e-mail: user-help@velocity.apache.org
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> >> > For additional commands, e-mail: user-help@velocity.apache.org
>> >> >
>> >> >
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> >> For additional commands, e-mail: user-help@velocity.apache.org
>> >>
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: user-help@velocity.apache.org
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
sadly, no. no one has written such a document yet. but here's a
sketch outline:
first, just drop in the Tools 2 jar as a straight up replacement.
assuming your app already worked great with Tools 1.3+, it should just
work. if not, let us know. we're trying to be fully backwards
compatible (though we did drop some stuff that's was deprecated in
1.3).
when you run that, look for any upgrade/deprecation notices in the
logs. that might help give details for the rest. (not sure on that
though)
next, try adjusting to the new package locations for things like the
VelocityViewServlet and VelocityLayoutServlet. Quick guide would be
that things in org.apache.velocity.tools.view.servlet and
org.apache.velocity.tools.view.context are now just in
org.apache.velocity.tools.view.
if you specifically reference the o.a.v.t.view.servlet.WebappLoader,
it is now the o.a.v.t.view.WebappResourceLoader.
now, since Tools 2 does lazy loading of tools, it now costs very
little per-request to have a lot of tools available. so, unless the
user is doing something to trigger the "deprecation support mode" for
VelocityView (using the old xml format would trigger this), all of the
standard VelocityTools will be automatically made available by
default. so, if you don't custom configure any of the provided tools
and don't have any custom tools of your own, then you don't actually
need a configuration.
if you do need a configuration, try switching your configuration to
the new format. easiest would be to go from the old xml format to the
new xml format:
http://velocity.apache.org/tools/devel/config.xml.html
remember, you can just leave out standard tools that you don't do any
configuration of.
if you do configure some of the standard tools, then while you are
updating the configuration format, you might also check to see if that
tool has been moved to a new package. the easiest way is probably
just to check in the javadoc. tools which are deprecated should tell
you what their replacement is. a few tools also had name changes
(e.g. ParameterParser to ParameterTool and BrowserSniffer to
BrowserTool)
that should cover most everything, except how to upgrade your custom
tools to do things the Tools 2 way. here's a few quick starts for
that, though this doesn't cover everything:
the recommended practice is to give a tool to be used as $foo the name
FooTool. not required, but it makes things easier for people to
follow and learn. if you are going name a tool FooBarUtility but want
it to be $foo in the context, the second best thing is to provide a
@DefaultKey("foo") annotation on the class.
also, if your tool is only meant to be used in a particular scope,
it's recommended that you give the class a @ValidScope(Scope.REQUEST)
annotation as well. if you only want to ban a particular scope and
allow all others, you could provide a @InvalidScope(Scope.APPLICATION)
annotation on the class. the Scope class provides constants for
REQUEST, SESSION, and APPLICATION. i believe other scopes are now
theoretically possible, but only a little work and less testing has
been done there.
if you have a configurable tool whose configuration should not changed
by the templates which use it, then consider having your tool extend
the AbstractLockConfig class (or one of its kin FormatConfig or
LocaleConfig). if you want to know more about these, let me know.
in general, the configure(Map) and init(Object) methods have been
changed into just the configure(Map) and individual setter methods
(e.g. setRequest, setSession, etc). basically, when it's time to
instantiate a tool, the tool manager will gather all the configuration
properties for that tool, its toolbox, etc and combine it into a
single map with the init data (context, request, session, etc). the
manager searches for relevant setter methods that accept that data and
also for a configure(Map) method. the setters get what they're asking
for (if available) and the configure method accepts the whole combined
Map. the upshot of this approach is that tools no longer need to
conform to any interfaces or patterns. in fact, it's possible to
write a FooTool that doesn't know anything about any VelocityTools
classes whatsoever and yet be fully instantiable and configurable by
VelocityTools. your tools don't need to know about anything except
what they need to know about.
and that all turned out longer than planned. i guess i have the start
of a migration document now, eh? let me know how it works out for
you.
On Tue, Apr 1, 2008 at 12:32 PM, Charles Harvey III <ch...@alloy.com> wrote:
> I would like to start migrating my tools to the 2.0 path. Is there a
> good document
> on the site that tells me how to do do? I have been looking and I'm not
> sure if I
> am looking in the right places.
>
> Thanks.
>
>
> Charlie
>
>
> Nathan Bubna said the following on 4/1/2008 3:16 PM:
>
>
> > yep, that's the idea. as for the init() method, you only need it if
> > your tool needs access to the initData for that scope (ServletContext
> > for application scope and ViewContext for request or session scope).
> > if your tool doesn't need access to any of those things, then it
> > doesn't need an init(Object) method.
> >
> > of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
> > things get even easier. :)
> >
> > On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com> wrote:
> >
> >> As far as your own tools goes, I want to make sure I've got it right:
> >>
> >> Old:
> >> -------------------------------------------------------------
> >> public class MyTool implements ViewTool
> >> {
> >> private String theString;
> >>
> >> public void init( Object o )
> >> {
> >> if( !( obj instanceof ViewContext ) )
> >> {
> >> throw new IllegalArgumentException( "Tool can only be
> >> initialized with a ViewContext" );
> >> }
> >> }
> >>
> >> public String getTheString()
> >> {
> >> return "this string comes from a velocity tool";
> >> }
> >> }
> >> -------------------------------------------------------------
> >>
> >>
> >> New:
> >> -------------------------------------------------------------
> >> public class MyTool
> >> {
> >> private String theString;
> >>
> >> public void init( Object o )
> >> {
> >> if( !( obj instanceof ViewContext ) )
> >> {
> >> throw new IllegalArgumentException( "Tool can only be
> >> initialized with a ViewContext" );
> >> }
> >> }
> >>
> >> public String getTheString()
> >> {
> >> return "this string comes from a velocity tool";
> >> }
> >> }
> >> -------------------------------------------------------------
> >>
> >>
> >> Do I still need the init method? Or can I skip that too?
> >>
> >> Thanks.
> >>
> >>
> >> Charlie
> >>
> >>
> >>
> >>
> >>
> >> Nathan Bubna said the following on 4/1/2008 1:06 PM:
> >>
> >>
> >>
> >>> there are some issues with multi-line comments within macros in Velocity 1.5
> >>>
> >> >
> >> > if you have written your own custom tools, then you'll find the
> >> > ViewTool and Configurable interfaces have been axed in VelocityTools
> >> > 1.4. just remove the implements declarations for those interfaces.
> >> > they are unnecessary, as Tools 1.4 will automatically look for their
> >> > methods in any tool class. if you haven't written any tools of your
> >> > own, i don't think there's anything to be concerned about.
> >> >
> >> > that's all i can think of right now, but of course, feel free to ask
> >> > questions/report problems here.
> >> >
> >> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
> >> >
> >> >> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
> >> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
> >> >> any gotchas I should watch out for?
> >> >>
> >> >> --
> >> >> ____________________________________________________________
> >> >> Glenn Holmer gholmer@weycogroup.com
> >> >> Software Engineer phone: 414-908-1809
> >> >> Weyco Group, Inc. fax: 414-908-1601
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> >> For additional commands, e-mail: user-help@velocity.apache.org
> >> >>
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> > For additional commands, e-mail: user-help@velocity.apache.org
> >> >
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: user-help@velocity.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
I would like to start migrating my tools to the 2.0 path. Is there a
good document
on the site that tells me how to do do? I have been looking and I'm not
sure if I
am looking in the right places.
Thanks.
Charlie
Nathan Bubna said the following on 4/1/2008 3:16 PM:
> yep, that's the idea. as for the init() method, you only need it if
> your tool needs access to the initData for that scope (ServletContext
> for application scope and ViewContext for request or session scope).
> if your tool doesn't need access to any of those things, then it
> doesn't need an init(Object) method.
>
> of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
> things get even easier. :)
>
> On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com> wrote:
>
>> As far as your own tools goes, I want to make sure I've got it right:
>>
>> Old:
>> -------------------------------------------------------------
>> public class MyTool implements ViewTool
>> {
>> private String theString;
>>
>> public void init( Object o )
>> {
>> if( !( obj instanceof ViewContext ) )
>> {
>> throw new IllegalArgumentException( "Tool can only be
>> initialized with a ViewContext" );
>> }
>> }
>>
>> public String getTheString()
>> {
>> return "this string comes from a velocity tool";
>> }
>> }
>> -------------------------------------------------------------
>>
>>
>> New:
>> -------------------------------------------------------------
>> public class MyTool
>> {
>> private String theString;
>>
>> public void init( Object o )
>> {
>> if( !( obj instanceof ViewContext ) )
>> {
>> throw new IllegalArgumentException( "Tool can only be
>> initialized with a ViewContext" );
>> }
>> }
>>
>> public String getTheString()
>> {
>> return "this string comes from a velocity tool";
>> }
>> }
>> -------------------------------------------------------------
>>
>>
>> Do I still need the init method? Or can I skip that too?
>>
>> Thanks.
>>
>>
>> Charlie
>>
>>
>>
>>
>>
>> Nathan Bubna said the following on 4/1/2008 1:06 PM:
>>
>>
>>
>>> there are some issues with multi-line comments within macros in Velocity 1.5
>>>
>> >
>> > if you have written your own custom tools, then you'll find the
>> > ViewTool and Configurable interfaces have been axed in VelocityTools
>> > 1.4. just remove the implements declarations for those interfaces.
>> > they are unnecessary, as Tools 1.4 will automatically look for their
>> > methods in any tool class. if you haven't written any tools of your
>> > own, i don't think there's anything to be concerned about.
>> >
>> > that's all i can think of right now, but of course, feel free to ask
>> > questions/report problems here.
>> >
>> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
>> >
>> >> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
>> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
>> >> any gotchas I should watch out for?
>> >>
>> >> --
>> >> ____________________________________________________________
>> >> Glenn Holmer gholmer@weycogroup.com
>> >> Software Engineer phone: 414-908-1809
>> >> Weyco Group, Inc. fax: 414-908-1601
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> >> For additional commands, e-mail: user-help@velocity.apache.org
>> >>
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: user-help@velocity.apache.org
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
On Fri, Apr 4, 2008 at 11:23 AM, Charles Harvey III <ch...@alloy.com> wrote:
>
>
> > That method returns a org.apache.velocity.context.Context.
> >
> > --------------------------------------------------------------------------
> > protected Context createVelocityContext(
> > Map model, HttpServletRequest request, HttpServletResponse response)
> throws Exception {
> > // Create a ChainedContext instance.
> > ChainedContext velocityContext = new ChainedContext(
> > new VelocityContext(model), getVelocityEngine(), request,
> response, getServletContext());
> > // Load a Velocity Tools toolbox, if necessary.
> > if (getToolboxConfigLocation() != null) {
> > ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
> > getServletContext(), getToolboxConfigLocation());
> > Map toolboxContext = toolboxManager.getToolbox(velocityContext);
> > velocityContext.setToolbox(toolboxContext);
> > }
> > return velocityContext;
> > }
> > --------------------------------------------------------------------------
> >
> Taking a look at the above, can I just do this instead?
>
>
> protected Context createVelocityContext( Map model, HttpServletRequest
> request,
> HttpServletResponse response ) throws Exception
> {
> ViewToolContext velocityContext = new ViewToolContext(
> getVelocityEngine(),
> request, response, getServletContext() );
> return velocityContext;
> }
>
> Looking at the "ViewToolContext" it seems to create the toolbox
> auto-magically.
> Is that so? Or am I missing something?
though i essentially answered this question in my last email, i'll add
some info here for general education:
no, the ViewToolContext doesn't auto-magically create toolboxes. it
only finds them auto-magically. in order to make tools more easily
accessible, the actual Toolboxes are put into the
request/session/servletContext attributes after being created by the
ToolboxFactory. the ViewToolContext just knows how to find them
there.
this is so that apps don't have to use a Context implementation at all
to get access to tools, as some people wanted to use tools outside of
templates. :) it also gives frameworks some extra flexibility if they
want.
> Thanks again.
>
>
>
>
> Charlie
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
> That method returns a org.apache.velocity.context.Context.
>
> --------------------------------------------------------------------------
>
> protected Context createVelocityContext(
> Map model, HttpServletRequest request, HttpServletResponse
> response) throws Exception {
> // Create a ChainedContext instance.
> ChainedContext velocityContext = new ChainedContext(
> new VelocityContext(model), getVelocityEngine(), request,
> response, getServletContext());
> // Load a Velocity Tools toolbox, if necessary.
> if (getToolboxConfigLocation() != null) {
> ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
> getServletContext(), getToolboxConfigLocation());
> Map toolboxContext = toolboxManager.getToolbox(velocityContext);
> velocityContext.setToolbox(toolboxContext);
> }
> return velocityContext;
> }
> --------------------------------------------------------------------------
>
Taking a look at the above, can I just do this instead?
protected Context createVelocityContext( Map model, HttpServletRequest
request,
HttpServletResponse response ) throws Exception
{
ViewToolContext velocityContext = new ViewToolContext(
getVelocityEngine(),
request, response, getServletContext() );
return velocityContext;
}
Looking at the "ViewToolContext" it seems to create the toolbox
auto-magically.
Is that so? Or am I missing something?
Thanks again.
Charlie
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
On Wed, May 14, 2008 at 9:30 AM, Charles Harvey III <ch...@alloy.com> wrote:
> D'oh! I spoke too soon. I had Spring pointing at toolbox.xml and not
> tools.xml.
ah. well, it's still good that you were able to drop in the Tools 2
jar and have things work as they used to, even if no new stuff worked.
> When I made the change none of the tools were initiated. I have to go back
> to
> the classes I had created before to replace the Spring ones:
>
>
> org.springframework.web.servlet.view.velocity.VelocityView
> -->> org.springframework.web.servlet.view.velocity.Velocity2View
>
> Where I replace their createContext() method with one that does not use the
> old
> ChainedContext with one that uses the new VelocityView.
>
> I'll let you know how it turns out.
thanks! things should be easier using the Tools 2 snapshot you built,
since i made it possible to instantiate a VelocityView from filter.
Let me know if/when you have questions. Obviously, i'm pretty
interested in making Tools 2/framework integration work as smoothly as
possible.
>
>
> Charlie
>
>
>
> Nathan Bubna said the following on 5/13/2008 6:25 PM:
>
>
>
> > That's great news! Thanks for the update. Hopefully i'll get my act
> > together and push out 2.0-beta2 in the next week. No promises, of
> > course. :)
> >
> > On Tue, May 13, 2008 at 2:34 PM, Charles Harvey III <ch...@alloy.com>
> wrote:
> >
> >
> > > Nathan,
> > > I of course never got around to doing any of this work. But I checked
> > > Subversion
> > > and saw that you had been making lots of changes.
> > >
> > > So I checked out the code last night and did a build of 2.0-SNAPSHOT,
> > > dropped it
> > > into my project and lo and behold, it worked! No changes. I had my
> own
> > > tools
> > > ready for tools-1.4 (which meant taking out the dependency) so
> everything
> > > was
> > > ready.
> > >
> > > I went from
> > > spring-1.2.9.jar
> > > velocity-tools-1.4.jar
> > >
> > > to
> > > spring-2.5.4.jar
> > > spring-web-2.5.4.jar
> > > spring-webmvc-2.5.4.jar (the Spring people broke out more code in the
> new
> > > version)
> > > velocity-tools-2.0-SNAPSHOT.jar
> > >
> > > And everything is great. Great stuff. Thanks so much for taking the
> time
> > > to work
> > > on all of this.
> > >
> > >
> > >
> > > Charlie
> > >
> > >
> > >
> > > Nathan Bubna said the following on 4/17/2008 11:53 PM:
> > >
> > >
> > >
> > >
> > > > Hey Charlie,
> > > >
> > > > Any luck getting this to work yet? Just curious...
> > > >
> > > > thanks,
> > > > nathan
> > > >
> > > > On Tue, Apr 8, 2008 at 3:15 PM, Nathan Bubna <nb...@gmail.com> wrote:
> > > >
> > > >
> > > >
> > > >
> > > > > On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III
> <ch...@alloy.com>
> > > > >
> > > > >
> > > >
> > > wrote:
> > >
> > >
> > > >
> > > > > > Ok. I tried and tried and I cannot get the ServletConfig to
> where I
> > > > >
> > > > >
> > > >
> > > need it
> > >
> > >
> > > >
> > > > > > so
> > > > > > I can create a new VelocityView. The best I can get is a
> > > > >
> > > > >
> > > >
> > > ServletContext.
> > >
> > >
> > > >
> > > > > That is a bummer. Thank you! Seriously, this exposes a signficant
> > > > > shortcoming in the plans to make it easy to integrate Tools into
> other
> > > > > frameworks. It also made me realize that i didn't provide proper
> > > > > Filter support either. It needs to be easier to init() a
> VelocityView
> > > > > (whether with a ServletConfig, FilterConfig or neither). I'll try
> to
> > > > > set aside some time to fix that this week. It'll mean we need to
> do
> > > > > another beta, i'm sure, but i think it'll be well worth it.
> > > > >
> > > > >
> > > > > >
> ------------------------------------------------------------------
> > > > > > VelocityView velocityView = new VelocityView(
> getServletContext() );
> > > > > > Context context = velocityView.getContext( request, response );
> > > > > >
> ------------------------------------------------------------------
> > > > > >
> > > > > > And, looking at the code for VelocityView, when you create a new
> > > > > > VelocityView
> > > > > > with a ServletContext, it never calls the init(ServletConfig
> config)
> > > > > > method.
> > > > > > So, the tools don't get configured. When I do
> $params.get('thing')
> > > > >
> > > > >
> > > >
> > > it
> > >
> > >
> > > >
> > > > > > tells me:
> > > > > >
> > > > > > Request is null. ParameterTool must be initialized first!
> > > > >
> > > > > Actually, this means the tools did get configured. This just means
> > > > > that the tool was never given access to the HttpServletRequest; the
> > > > > tools aren't being properly initialized.
> > > > >
> > > > > You could just precede $params.thing with
> $params.setRequest($request)
> > > > > to make this work, but obviously that shouldn't be necessary and
> would
> > > > > not work for tools who use configure() instead of setters.
> > > > >
> > > > >
> > > > > > So, I tried it the "standalone" way:
> > > > > >
> ------------------------------------------------------------------
> > > > > > ToolManager manager = new ToolManager();
> > > > > > if( getToolboxConfigLocation() != null )
> > > > > > {
> > > > > > manager.configure( getServletContext().getRealPath(
> > > > > > getToolboxConfigLocation() ) );
> > > > > > }
> > > > > > manager.setVelocityEngine( getVelocityEngine() );
> > > > > > Context context = manager.createContext();
> > > > > >
> ------------------------------------------------------------------
> > > > > >
> > > > > > And I get the same result.
> > > > >
> > > > > As expected. The code above has no knowledge of ServletRequests,
> so
> > > > > it would be unable to tell tools about them.
> > > > >
> > > > >
> > > > > > One other attempt was made:
> > > > > >
> ------------------------------------------------------------------
> > > > > > ViewToolContext context = new ViewToolContext(
> getVelocityEngine(),
> > > > > > request, response,
> > > > > > getServletContext() );
> > > > > >
> ------------------------------------------------------------------
> > > > > >
> > > > > > This time, no errors. But the tools don't work. I see a bunch
> of
> > > > > > $link.setRelative()
> > > > > > all over the page. Nothing renders.
> > > > >
> > > > > That's because the ViewToolContext only knows how to find tools.
> It
> > > > > doesn't create them at all.
> > > > >
> > > > >
> > > > > >
> > > > > > Am I close? Way off? Any help is much appreciated.
> > > > > >
> > > > >
> > > > > Your last example is actually headed in the right direction.
> > > > > Unfortunately, since you can't use VelocityView until i fix it,
> it's a
> > > > > little more complicated. Here's the gist, though i'll have to
> leave
> > > > > you to fill in the blanks for the moment:
> > > > >
> > > > > the first goal is to create a FactoryConfiguration, then configure
> a
> > > > > new ToolboxFactory instance with that config. this may look
> something
> > > > > like this (see VelocityView.configure(ServletConfig,
> ToolboxFactory)
> > > > > for a much more involved example):
> > > > >
> > > > > FactoryConfiguration config = ConfigurationUtils.getAutoLoaded();
> //
> > > > > read javadoc on this!
> > > > > ToolboxFactory factory = new ToolboxFactory();
> > > > > factory.configure(config);
> > > > >
> > > > > keep this factory around for the life of the app. you only want
> the
> > > > > code above to happen once, not on every request!
> > > > >
> > > > > this once-per-app initialization is also a good place to create
> your
> > > > > application-scoped toolbox and put that in the servlet context.
> that
> > > > > code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
> > > > > and looks roughly like this:
> > > > >
> > > > > Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
> > > > > if (appTools != null &&
> > > > > servletContext.getAttribute(Toolbox.class.getName()) ==
> null)
> > > > > {
> > > > > servletContext.setAttribute(Toolbox.class.getName(),
> > > > >
> > > > >
> > > >
> > > appTools);
> > >
> > >
> > > >
> > > > > }
> > > > >
> > > > >
> > > > > with that, the application level stuff should be ready to go; now
> we
> > > > > just need to prep some things before every request. so, before you
> > > > > create that ViewToolContext in your last example above, use your
> > > > > ToolboxFactory and do the following (this code is ripped from
> > > > > VelocityView.prepareToolboxes()):
> > > > >
> > > > > String key = Toolbox.class.getName();
> > > > > if (factory.hasTools(Scope.REQUEST)
> > > > > && request.getAttribute(key) == null)
> > > > > {
> > > > > // add request toolbox, if any
> > > > > Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
> > > > > if (reqTools != null)
> > > > > {
> > > > > request.setAttribute(key, reqTools);
> > > > > }
> > > > > }
> > > > >
> > > > > if (factory.hasTools("session"))
> > > > > {
> > > > > HttpSession session = request.getSession(true);
> > > > > // allow only one thread at a time
> > > > > synchronized(factory)
> > > > > {
> > > > > if (session.getAttribute(key) == null)
> > > > > {
> > > > > Toolbox sessTools =
> > > > > factory.createToolbox("session");
> > > > > session.setAttribute(key, sessTools);
> > > > > }
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > > This creates the Toolbox instances for the current session and
> request
> > > > > and puts them where the ViewToolContext can find them. Once all of
> > > > > the above is done, create your ViewToolContext and return that.
> > > > >
> > > > > i think that should do the trick. sorry this is more complicated
> that
> > > > > i'd hoped. i'll try and whip the VelocityView init code into
> > > > > something more forgiving and get a new beta out. Thanks for
> bringing
> > > > > attention to this deficit. :)
> > > > >
> > > > >
> > > > >
> > > > > > Thanks again.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Charlie
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > ---------------------------------------------------------------------
> > >
> > >
> > > >
> > > > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: user-help@velocity.apache.org
> > >
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
D'oh! I spoke too soon. I had Spring pointing at toolbox.xml and not
tools.xml.
When I made the change none of the tools were initiated. I have to go
back to
the classes I had created before to replace the Spring ones:
org.springframework.web.servlet.view.velocity.VelocityView
-->> org.springframework.web.servlet.view.velocity.Velocity2View
Where I replace their createContext() method with one that does not use
the old
ChainedContext with one that uses the new VelocityView.
I'll let you know how it turns out.
Charlie
Nathan Bubna said the following on 5/13/2008 6:25 PM:
> That's great news! Thanks for the update. Hopefully i'll get my act
> together and push out 2.0-beta2 in the next week. No promises, of
> course. :)
>
> On Tue, May 13, 2008 at 2:34 PM, Charles Harvey III <ch...@alloy.com> wrote:
>
>> Nathan,
>> I of course never got around to doing any of this work. But I checked
>> Subversion
>> and saw that you had been making lots of changes.
>>
>> So I checked out the code last night and did a build of 2.0-SNAPSHOT,
>> dropped it
>> into my project and lo and behold, it worked! No changes. I had my own
>> tools
>> ready for tools-1.4 (which meant taking out the dependency) so everything
>> was
>> ready.
>>
>> I went from
>> spring-1.2.9.jar
>> velocity-tools-1.4.jar
>>
>> to
>> spring-2.5.4.jar
>> spring-web-2.5.4.jar
>> spring-webmvc-2.5.4.jar (the Spring people broke out more code in the new
>> version)
>> velocity-tools-2.0-SNAPSHOT.jar
>>
>> And everything is great. Great stuff. Thanks so much for taking the time
>> to work
>> on all of this.
>>
>>
>>
>> Charlie
>>
>>
>>
>> Nathan Bubna said the following on 4/17/2008 11:53 PM:
>>
>>
>>
>>> Hey Charlie,
>>>
>>> Any luck getting this to work yet? Just curious...
>>>
>>> thanks,
>>> nathan
>>>
>>> On Tue, Apr 8, 2008 at 3:15 PM, Nathan Bubna <nb...@gmail.com> wrote:
>>>
>>>
>>>
>>>> On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com>
>>>>
>> wrote:
>>
>>>> > Ok. I tried and tried and I cannot get the ServletConfig to where I
>>>>
>> need it
>>
>>>> > so
>>>> > I can create a new VelocityView. The best I can get is a
>>>>
>> ServletContext.
>>
>>>> That is a bummer. Thank you! Seriously, this exposes a signficant
>>>> shortcoming in the plans to make it easy to integrate Tools into other
>>>> frameworks. It also made me realize that i didn't provide proper
>>>> Filter support either. It needs to be easier to init() a VelocityView
>>>> (whether with a ServletConfig, FilterConfig or neither). I'll try to
>>>> set aside some time to fix that this week. It'll mean we need to do
>>>> another beta, i'm sure, but i think it'll be well worth it.
>>>>
>>>>
>>>> > ------------------------------------------------------------------
>>>> > VelocityView velocityView = new VelocityView( getServletContext() );
>>>> > Context context = velocityView.getContext( request, response );
>>>> > ------------------------------------------------------------------
>>>> >
>>>> > And, looking at the code for VelocityView, when you create a new
>>>> > VelocityView
>>>> > with a ServletContext, it never calls the init(ServletConfig config)
>>>> > method.
>>>> > So, the tools don't get configured. When I do $params.get('thing')
>>>>
>> it
>>
>>>> > tells me:
>>>> >
>>>> > Request is null. ParameterTool must be initialized first!
>>>>
>>>> Actually, this means the tools did get configured. This just means
>>>> that the tool was never given access to the HttpServletRequest; the
>>>> tools aren't being properly initialized.
>>>>
>>>> You could just precede $params.thing with $params.setRequest($request)
>>>> to make this work, but obviously that shouldn't be necessary and would
>>>> not work for tools who use configure() instead of setters.
>>>>
>>>>
>>>> > So, I tried it the "standalone" way:
>>>> > ------------------------------------------------------------------
>>>> > ToolManager manager = new ToolManager();
>>>> > if( getToolboxConfigLocation() != null )
>>>> > {
>>>> > manager.configure( getServletContext().getRealPath(
>>>> > getToolboxConfigLocation() ) );
>>>> > }
>>>> > manager.setVelocityEngine( getVelocityEngine() );
>>>> > Context context = manager.createContext();
>>>> > ------------------------------------------------------------------
>>>> >
>>>> > And I get the same result.
>>>>
>>>> As expected. The code above has no knowledge of ServletRequests, so
>>>> it would be unable to tell tools about them.
>>>>
>>>>
>>>> > One other attempt was made:
>>>> > ------------------------------------------------------------------
>>>> > ViewToolContext context = new ViewToolContext( getVelocityEngine(),
>>>> > request, response,
>>>> > getServletContext() );
>>>> > ------------------------------------------------------------------
>>>> >
>>>> > This time, no errors. But the tools don't work. I see a bunch of
>>>> > $link.setRelative()
>>>> > all over the page. Nothing renders.
>>>>
>>>> That's because the ViewToolContext only knows how to find tools. It
>>>> doesn't create them at all.
>>>>
>>>>
>>>> >
>>>> > Am I close? Way off? Any help is much appreciated.
>>>> >
>>>>
>>>> Your last example is actually headed in the right direction.
>>>> Unfortunately, since you can't use VelocityView until i fix it, it's a
>>>> little more complicated. Here's the gist, though i'll have to leave
>>>> you to fill in the blanks for the moment:
>>>>
>>>> the first goal is to create a FactoryConfiguration, then configure a
>>>> new ToolboxFactory instance with that config. this may look something
>>>> like this (see VelocityView.configure(ServletConfig, ToolboxFactory)
>>>> for a much more involved example):
>>>>
>>>> FactoryConfiguration config = ConfigurationUtils.getAutoLoaded(); //
>>>> read javadoc on this!
>>>> ToolboxFactory factory = new ToolboxFactory();
>>>> factory.configure(config);
>>>>
>>>> keep this factory around for the life of the app. you only want the
>>>> code above to happen once, not on every request!
>>>>
>>>> this once-per-app initialization is also a good place to create your
>>>> application-scoped toolbox and put that in the servlet context. that
>>>> code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
>>>> and looks roughly like this:
>>>>
>>>> Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
>>>> if (appTools != null &&
>>>> servletContext.getAttribute(Toolbox.class.getName()) == null)
>>>> {
>>>> servletContext.setAttribute(Toolbox.class.getName(),
>>>>
>> appTools);
>>
>>>> }
>>>>
>>>>
>>>> with that, the application level stuff should be ready to go; now we
>>>> just need to prep some things before every request. so, before you
>>>> create that ViewToolContext in your last example above, use your
>>>> ToolboxFactory and do the following (this code is ripped from
>>>> VelocityView.prepareToolboxes()):
>>>>
>>>> String key = Toolbox.class.getName();
>>>> if (factory.hasTools(Scope.REQUEST)
>>>> && request.getAttribute(key) == null)
>>>> {
>>>> // add request toolbox, if any
>>>> Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
>>>> if (reqTools != null)
>>>> {
>>>> request.setAttribute(key, reqTools);
>>>> }
>>>> }
>>>>
>>>> if (factory.hasTools("session"))
>>>> {
>>>> HttpSession session = request.getSession(true);
>>>> // allow only one thread at a time
>>>> synchronized(factory)
>>>> {
>>>> if (session.getAttribute(key) == null)
>>>> {
>>>> Toolbox sessTools =
>>>> factory.createToolbox("session");
>>>> session.setAttribute(key, sessTools);
>>>> }
>>>> }
>>>> }
>>>>
>>>>
>>>> This creates the Toolbox instances for the current session and request
>>>> and puts them where the ViewToolContext can find them. Once all of
>>>> the above is done, create your ViewToolContext and return that.
>>>>
>>>> i think that should do the trick. sorry this is more complicated that
>>>> i'd hoped. i'll try and whip the VelocityView init code into
>>>> something more forgiving and get a new beta out. Thanks for bringing
>>>> attention to this deficit. :)
>>>>
>>>>
>>>>
>>>> > Thanks again.
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > Charlie
>>>> >
>>>> >
>>>> >
>>>>
>> ---------------------------------------------------------------------
>>
>>>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>>> > For additional commands, e-mail: user-help@velocity.apache.org
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
That's great news! Thanks for the update. Hopefully i'll get my act
together and push out 2.0-beta2 in the next week. No promises, of
course. :)
On Tue, May 13, 2008 at 2:34 PM, Charles Harvey III <ch...@alloy.com> wrote:
> Nathan,
> I of course never got around to doing any of this work. But I checked
> Subversion
> and saw that you had been making lots of changes.
>
> So I checked out the code last night and did a build of 2.0-SNAPSHOT,
> dropped it
> into my project and lo and behold, it worked! No changes. I had my own
> tools
> ready for tools-1.4 (which meant taking out the dependency) so everything
> was
> ready.
>
> I went from
> spring-1.2.9.jar
> velocity-tools-1.4.jar
>
> to
> spring-2.5.4.jar
> spring-web-2.5.4.jar
> spring-webmvc-2.5.4.jar (the Spring people broke out more code in the new
> version)
> velocity-tools-2.0-SNAPSHOT.jar
>
> And everything is great. Great stuff. Thanks so much for taking the time
> to work
> on all of this.
>
>
>
> Charlie
>
>
>
> Nathan Bubna said the following on 4/17/2008 11:53 PM:
>
>
> > Hey Charlie,
> >
> > Any luck getting this to work yet? Just curious...
> >
> > thanks,
> > nathan
> >
> > On Tue, Apr 8, 2008 at 3:15 PM, Nathan Bubna <nb...@gmail.com> wrote:
> >
> >
> > > On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com>
> wrote:
> > > > Ok. I tried and tried and I cannot get the ServletConfig to where I
> need it
> > > > so
> > > > I can create a new VelocityView. The best I can get is a
> ServletContext.
> > >
> > > That is a bummer. Thank you! Seriously, this exposes a signficant
> > > shortcoming in the plans to make it easy to integrate Tools into other
> > > frameworks. It also made me realize that i didn't provide proper
> > > Filter support either. It needs to be easier to init() a VelocityView
> > > (whether with a ServletConfig, FilterConfig or neither). I'll try to
> > > set aside some time to fix that this week. It'll mean we need to do
> > > another beta, i'm sure, but i think it'll be well worth it.
> > >
> > >
> > > > ------------------------------------------------------------------
> > > > VelocityView velocityView = new VelocityView( getServletContext() );
> > > > Context context = velocityView.getContext( request, response );
> > > > ------------------------------------------------------------------
> > > >
> > > > And, looking at the code for VelocityView, when you create a new
> > > > VelocityView
> > > > with a ServletContext, it never calls the init(ServletConfig config)
> > > > method.
> > > > So, the tools don't get configured. When I do $params.get('thing')
> it
> > > > tells me:
> > > >
> > > > Request is null. ParameterTool must be initialized first!
> > >
> > > Actually, this means the tools did get configured. This just means
> > > that the tool was never given access to the HttpServletRequest; the
> > > tools aren't being properly initialized.
> > >
> > > You could just precede $params.thing with $params.setRequest($request)
> > > to make this work, but obviously that shouldn't be necessary and would
> > > not work for tools who use configure() instead of setters.
> > >
> > >
> > > > So, I tried it the "standalone" way:
> > > > ------------------------------------------------------------------
> > > > ToolManager manager = new ToolManager();
> > > > if( getToolboxConfigLocation() != null )
> > > > {
> > > > manager.configure( getServletContext().getRealPath(
> > > > getToolboxConfigLocation() ) );
> > > > }
> > > > manager.setVelocityEngine( getVelocityEngine() );
> > > > Context context = manager.createContext();
> > > > ------------------------------------------------------------------
> > > >
> > > > And I get the same result.
> > >
> > > As expected. The code above has no knowledge of ServletRequests, so
> > > it would be unable to tell tools about them.
> > >
> > >
> > > > One other attempt was made:
> > > > ------------------------------------------------------------------
> > > > ViewToolContext context = new ViewToolContext( getVelocityEngine(),
> > > > request, response,
> > > > getServletContext() );
> > > > ------------------------------------------------------------------
> > > >
> > > > This time, no errors. But the tools don't work. I see a bunch of
> > > > $link.setRelative()
> > > > all over the page. Nothing renders.
> > >
> > > That's because the ViewToolContext only knows how to find tools. It
> > > doesn't create them at all.
> > >
> > >
> > > >
> > > > Am I close? Way off? Any help is much appreciated.
> > > >
> > >
> > > Your last example is actually headed in the right direction.
> > > Unfortunately, since you can't use VelocityView until i fix it, it's a
> > > little more complicated. Here's the gist, though i'll have to leave
> > > you to fill in the blanks for the moment:
> > >
> > > the first goal is to create a FactoryConfiguration, then configure a
> > > new ToolboxFactory instance with that config. this may look something
> > > like this (see VelocityView.configure(ServletConfig, ToolboxFactory)
> > > for a much more involved example):
> > >
> > > FactoryConfiguration config = ConfigurationUtils.getAutoLoaded(); //
> > > read javadoc on this!
> > > ToolboxFactory factory = new ToolboxFactory();
> > > factory.configure(config);
> > >
> > > keep this factory around for the life of the app. you only want the
> > > code above to happen once, not on every request!
> > >
> > > this once-per-app initialization is also a good place to create your
> > > application-scoped toolbox and put that in the servlet context. that
> > > code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
> > > and looks roughly like this:
> > >
> > > Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
> > > if (appTools != null &&
> > > servletContext.getAttribute(Toolbox.class.getName()) == null)
> > > {
> > > servletContext.setAttribute(Toolbox.class.getName(),
> appTools);
> > > }
> > >
> > >
> > > with that, the application level stuff should be ready to go; now we
> > > just need to prep some things before every request. so, before you
> > > create that ViewToolContext in your last example above, use your
> > > ToolboxFactory and do the following (this code is ripped from
> > > VelocityView.prepareToolboxes()):
> > >
> > > String key = Toolbox.class.getName();
> > > if (factory.hasTools(Scope.REQUEST)
> > > && request.getAttribute(key) == null)
> > > {
> > > // add request toolbox, if any
> > > Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
> > > if (reqTools != null)
> > > {
> > > request.setAttribute(key, reqTools);
> > > }
> > > }
> > >
> > > if (factory.hasTools("session"))
> > > {
> > > HttpSession session = request.getSession(true);
> > > // allow only one thread at a time
> > > synchronized(factory)
> > > {
> > > if (session.getAttribute(key) == null)
> > > {
> > > Toolbox sessTools =
> > > factory.createToolbox("session");
> > > session.setAttribute(key, sessTools);
> > > }
> > > }
> > > }
> > >
> > >
> > > This creates the Toolbox instances for the current session and request
> > > and puts them where the ViewToolContext can find them. Once all of
> > > the above is done, create your ViewToolContext and return that.
> > >
> > > i think that should do the trick. sorry this is more complicated that
> > > i'd hoped. i'll try and whip the VelocityView init code into
> > > something more forgiving and get a new beta out. Thanks for bringing
> > > attention to this deficit. :)
> > >
> > >
> > >
> > > > Thanks again.
> > > >
> > > >
> > > >
> > > >
> > > > Charlie
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > >
> > > >
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
Nathan,
I of course never got around to doing any of this work. But I checked
Subversion
and saw that you had been making lots of changes.
So I checked out the code last night and did a build of 2.0-SNAPSHOT,
dropped it
into my project and lo and behold, it worked! No changes. I had my own
tools
ready for tools-1.4 (which meant taking out the dependency) so
everything was
ready.
I went from
spring-1.2.9.jar
velocity-tools-1.4.jar
to
spring-2.5.4.jar
spring-web-2.5.4.jar
spring-webmvc-2.5.4.jar (the Spring people broke out more code in the
new version)
velocity-tools-2.0-SNAPSHOT.jar
And everything is great. Great stuff. Thanks so much for taking the
time to work
on all of this.
Charlie
Nathan Bubna said the following on 4/17/2008 11:53 PM:
> Hey Charlie,
>
> Any luck getting this to work yet? Just curious...
>
> thanks,
> nathan
>
> On Tue, Apr 8, 2008 at 3:15 PM, Nathan Bubna <nb...@gmail.com> wrote:
>
>> On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com> wrote:
>> > Ok. I tried and tried and I cannot get the ServletConfig to where I need it
>> > so
>> > I can create a new VelocityView. The best I can get is a ServletContext.
>>
>> That is a bummer. Thank you! Seriously, this exposes a signficant
>> shortcoming in the plans to make it easy to integrate Tools into other
>> frameworks. It also made me realize that i didn't provide proper
>> Filter support either. It needs to be easier to init() a VelocityView
>> (whether with a ServletConfig, FilterConfig or neither). I'll try to
>> set aside some time to fix that this week. It'll mean we need to do
>> another beta, i'm sure, but i think it'll be well worth it.
>>
>>
>> > ------------------------------------------------------------------
>> > VelocityView velocityView = new VelocityView( getServletContext() );
>> > Context context = velocityView.getContext( request, response );
>> > ------------------------------------------------------------------
>> >
>> > And, looking at the code for VelocityView, when you create a new
>> > VelocityView
>> > with a ServletContext, it never calls the init(ServletConfig config)
>> > method.
>> > So, the tools don't get configured. When I do $params.get('thing') it
>> > tells me:
>> >
>> > Request is null. ParameterTool must be initialized first!
>>
>> Actually, this means the tools did get configured. This just means
>> that the tool was never given access to the HttpServletRequest; the
>> tools aren't being properly initialized.
>>
>> You could just precede $params.thing with $params.setRequest($request)
>> to make this work, but obviously that shouldn't be necessary and would
>> not work for tools who use configure() instead of setters.
>>
>>
>> > So, I tried it the "standalone" way:
>> > ------------------------------------------------------------------
>> > ToolManager manager = new ToolManager();
>> > if( getToolboxConfigLocation() != null )
>> > {
>> > manager.configure( getServletContext().getRealPath(
>> > getToolboxConfigLocation() ) );
>> > }
>> > manager.setVelocityEngine( getVelocityEngine() );
>> > Context context = manager.createContext();
>> > ------------------------------------------------------------------
>> >
>> > And I get the same result.
>>
>> As expected. The code above has no knowledge of ServletRequests, so
>> it would be unable to tell tools about them.
>>
>>
>> > One other attempt was made:
>> > ------------------------------------------------------------------
>> > ViewToolContext context = new ViewToolContext( getVelocityEngine(),
>> > request, response,
>> > getServletContext() );
>> > ------------------------------------------------------------------
>> >
>> > This time, no errors. But the tools don't work. I see a bunch of
>> > $link.setRelative()
>> > all over the page. Nothing renders.
>>
>> That's because the ViewToolContext only knows how to find tools. It
>> doesn't create them at all.
>>
>>
>> >
>> > Am I close? Way off? Any help is much appreciated.
>> >
>>
>> Your last example is actually headed in the right direction.
>> Unfortunately, since you can't use VelocityView until i fix it, it's a
>> little more complicated. Here's the gist, though i'll have to leave
>> you to fill in the blanks for the moment:
>>
>> the first goal is to create a FactoryConfiguration, then configure a
>> new ToolboxFactory instance with that config. this may look something
>> like this (see VelocityView.configure(ServletConfig, ToolboxFactory)
>> for a much more involved example):
>>
>> FactoryConfiguration config = ConfigurationUtils.getAutoLoaded(); //
>> read javadoc on this!
>> ToolboxFactory factory = new ToolboxFactory();
>> factory.configure(config);
>>
>> keep this factory around for the life of the app. you only want the
>> code above to happen once, not on every request!
>>
>> this once-per-app initialization is also a good place to create your
>> application-scoped toolbox and put that in the servlet context. that
>> code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
>> and looks roughly like this:
>>
>> Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
>> if (appTools != null &&
>> servletContext.getAttribute(Toolbox.class.getName()) == null)
>> {
>> servletContext.setAttribute(Toolbox.class.getName(), appTools);
>> }
>>
>>
>> with that, the application level stuff should be ready to go; now we
>> just need to prep some things before every request. so, before you
>> create that ViewToolContext in your last example above, use your
>> ToolboxFactory and do the following (this code is ripped from
>> VelocityView.prepareToolboxes()):
>>
>> String key = Toolbox.class.getName();
>> if (factory.hasTools(Scope.REQUEST)
>> && request.getAttribute(key) == null)
>> {
>> // add request toolbox, if any
>> Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
>> if (reqTools != null)
>> {
>> request.setAttribute(key, reqTools);
>> }
>> }
>>
>> if (factory.hasTools("session"))
>> {
>> HttpSession session = request.getSession(true);
>> // allow only one thread at a time
>> synchronized(factory)
>> {
>> if (session.getAttribute(key) == null)
>> {
>> Toolbox sessTools =
>> factory.createToolbox("session");
>> session.setAttribute(key, sessTools);
>> }
>> }
>> }
>>
>>
>> This creates the Toolbox instances for the current session and request
>> and puts them where the ViewToolContext can find them. Once all of
>> the above is done, create your ViewToolContext and return that.
>>
>> i think that should do the trick. sorry this is more complicated that
>> i'd hoped. i'll try and whip the VelocityView init code into
>> something more forgiving and get a new beta out. Thanks for bringing
>> attention to this deficit. :)
>>
>>
>>
>> > Thanks again.
>> >
>> >
>> >
>> >
>> > Charlie
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: user-help@velocity.apache.org
>> >
>> >
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
You just reminded me. I have been a bit busy lately but I have some time
now so I'll give it a shot.
Charlie
Nathan Bubna said the following on 4/17/2008 11:53 PM:
> Hey Charlie,
>
> Any luck getting this to work yet? Just curious...
>
> thanks,
> nathan
>
> On Tue, Apr 8, 2008 at 3:15 PM, Nathan Bubna <nb...@gmail.com> wrote:
>
>> On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com> wrote:
>> > Ok. I tried and tried and I cannot get the ServletConfig to where I need it
>> > so
>> > I can create a new VelocityView. The best I can get is a ServletContext.
>>
>> That is a bummer. Thank you! Seriously, this exposes a signficant
>> shortcoming in the plans to make it easy to integrate Tools into other
>> frameworks. It also made me realize that i didn't provide proper
>> Filter support either. It needs to be easier to init() a VelocityView
>> (whether with a ServletConfig, FilterConfig or neither). I'll try to
>> set aside some time to fix that this week. It'll mean we need to do
>> another beta, i'm sure, but i think it'll be well worth it.
>>
>>
>> > ------------------------------------------------------------------
>> > VelocityView velocityView = new VelocityView( getServletContext() );
>> > Context context = velocityView.getContext( request, response );
>> > ------------------------------------------------------------------
>> >
>> > And, looking at the code for VelocityView, when you create a new
>> > VelocityView
>> > with a ServletContext, it never calls the init(ServletConfig config)
>> > method.
>> > So, the tools don't get configured. When I do $params.get('thing') it
>> > tells me:
>> >
>> > Request is null. ParameterTool must be initialized first!
>>
>> Actually, this means the tools did get configured. This just means
>> that the tool was never given access to the HttpServletRequest; the
>> tools aren't being properly initialized.
>>
>> You could just precede $params.thing with $params.setRequest($request)
>> to make this work, but obviously that shouldn't be necessary and would
>> not work for tools who use configure() instead of setters.
>>
>>
>> > So, I tried it the "standalone" way:
>> > ------------------------------------------------------------------
>> > ToolManager manager = new ToolManager();
>> > if( getToolboxConfigLocation() != null )
>> > {
>> > manager.configure( getServletContext().getRealPath(
>> > getToolboxConfigLocation() ) );
>> > }
>> > manager.setVelocityEngine( getVelocityEngine() );
>> > Context context = manager.createContext();
>> > ------------------------------------------------------------------
>> >
>> > And I get the same result.
>>
>> As expected. The code above has no knowledge of ServletRequests, so
>> it would be unable to tell tools about them.
>>
>>
>> > One other attempt was made:
>> > ------------------------------------------------------------------
>> > ViewToolContext context = new ViewToolContext( getVelocityEngine(),
>> > request, response,
>> > getServletContext() );
>> > ------------------------------------------------------------------
>> >
>> > This time, no errors. But the tools don't work. I see a bunch of
>> > $link.setRelative()
>> > all over the page. Nothing renders.
>>
>> That's because the ViewToolContext only knows how to find tools. It
>> doesn't create them at all.
>>
>>
>> >
>> > Am I close? Way off? Any help is much appreciated.
>> >
>>
>> Your last example is actually headed in the right direction.
>> Unfortunately, since you can't use VelocityView until i fix it, it's a
>> little more complicated. Here's the gist, though i'll have to leave
>> you to fill in the blanks for the moment:
>>
>> the first goal is to create a FactoryConfiguration, then configure a
>> new ToolboxFactory instance with that config. this may look something
>> like this (see VelocityView.configure(ServletConfig, ToolboxFactory)
>> for a much more involved example):
>>
>> FactoryConfiguration config = ConfigurationUtils.getAutoLoaded(); //
>> read javadoc on this!
>> ToolboxFactory factory = new ToolboxFactory();
>> factory.configure(config);
>>
>> keep this factory around for the life of the app. you only want the
>> code above to happen once, not on every request!
>>
>> this once-per-app initialization is also a good place to create your
>> application-scoped toolbox and put that in the servlet context. that
>> code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
>> and looks roughly like this:
>>
>> Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
>> if (appTools != null &&
>> servletContext.getAttribute(Toolbox.class.getName()) == null)
>> {
>> servletContext.setAttribute(Toolbox.class.getName(), appTools);
>> }
>>
>>
>> with that, the application level stuff should be ready to go; now we
>> just need to prep some things before every request. so, before you
>> create that ViewToolContext in your last example above, use your
>> ToolboxFactory and do the following (this code is ripped from
>> VelocityView.prepareToolboxes()):
>>
>> String key = Toolbox.class.getName();
>> if (factory.hasTools(Scope.REQUEST)
>> && request.getAttribute(key) == null)
>> {
>> // add request toolbox, if any
>> Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
>> if (reqTools != null)
>> {
>> request.setAttribute(key, reqTools);
>> }
>> }
>>
>> if (factory.hasTools("session"))
>> {
>> HttpSession session = request.getSession(true);
>> // allow only one thread at a time
>> synchronized(factory)
>> {
>> if (session.getAttribute(key) == null)
>> {
>> Toolbox sessTools =
>> factory.createToolbox("session");
>> session.setAttribute(key, sessTools);
>> }
>> }
>> }
>>
>>
>> This creates the Toolbox instances for the current session and request
>> and puts them where the ViewToolContext can find them. Once all of
>> the above is done, create your ViewToolContext and return that.
>>
>> i think that should do the trick. sorry this is more complicated that
>> i'd hoped. i'll try and whip the VelocityView init code into
>> something more forgiving and get a new beta out. Thanks for bringing
>> attention to this deficit. :)
>>
>>
>>
>> > Thanks again.
>> >
>> >
>> >
>> >
>> > Charlie
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: user-help@velocity.apache.org
>> >
>> >
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
Hey Charlie,
Any luck getting this to work yet? Just curious...
thanks,
nathan
On Tue, Apr 8, 2008 at 3:15 PM, Nathan Bubna <nb...@gmail.com> wrote:
> On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com> wrote:
> > Ok. I tried and tried and I cannot get the ServletConfig to where I need it
> > so
> > I can create a new VelocityView. The best I can get is a ServletContext.
>
> That is a bummer. Thank you! Seriously, this exposes a signficant
> shortcoming in the plans to make it easy to integrate Tools into other
> frameworks. It also made me realize that i didn't provide proper
> Filter support either. It needs to be easier to init() a VelocityView
> (whether with a ServletConfig, FilterConfig or neither). I'll try to
> set aside some time to fix that this week. It'll mean we need to do
> another beta, i'm sure, but i think it'll be well worth it.
>
>
> > ------------------------------------------------------------------
> > VelocityView velocityView = new VelocityView( getServletContext() );
> > Context context = velocityView.getContext( request, response );
> > ------------------------------------------------------------------
> >
> > And, looking at the code for VelocityView, when you create a new
> > VelocityView
> > with a ServletContext, it never calls the init(ServletConfig config)
> > method.
> > So, the tools don't get configured. When I do $params.get('thing') it
> > tells me:
> >
> > Request is null. ParameterTool must be initialized first!
>
> Actually, this means the tools did get configured. This just means
> that the tool was never given access to the HttpServletRequest; the
> tools aren't being properly initialized.
>
> You could just precede $params.thing with $params.setRequest($request)
> to make this work, but obviously that shouldn't be necessary and would
> not work for tools who use configure() instead of setters.
>
>
> > So, I tried it the "standalone" way:
> > ------------------------------------------------------------------
> > ToolManager manager = new ToolManager();
> > if( getToolboxConfigLocation() != null )
> > {
> > manager.configure( getServletContext().getRealPath(
> > getToolboxConfigLocation() ) );
> > }
> > manager.setVelocityEngine( getVelocityEngine() );
> > Context context = manager.createContext();
> > ------------------------------------------------------------------
> >
> > And I get the same result.
>
> As expected. The code above has no knowledge of ServletRequests, so
> it would be unable to tell tools about them.
>
>
> > One other attempt was made:
> > ------------------------------------------------------------------
> > ViewToolContext context = new ViewToolContext( getVelocityEngine(),
> > request, response,
> > getServletContext() );
> > ------------------------------------------------------------------
> >
> > This time, no errors. But the tools don't work. I see a bunch of
> > $link.setRelative()
> > all over the page. Nothing renders.
>
> That's because the ViewToolContext only knows how to find tools. It
> doesn't create them at all.
>
>
> >
> > Am I close? Way off? Any help is much appreciated.
> >
>
> Your last example is actually headed in the right direction.
> Unfortunately, since you can't use VelocityView until i fix it, it's a
> little more complicated. Here's the gist, though i'll have to leave
> you to fill in the blanks for the moment:
>
> the first goal is to create a FactoryConfiguration, then configure a
> new ToolboxFactory instance with that config. this may look something
> like this (see VelocityView.configure(ServletConfig, ToolboxFactory)
> for a much more involved example):
>
> FactoryConfiguration config = ConfigurationUtils.getAutoLoaded(); //
> read javadoc on this!
> ToolboxFactory factory = new ToolboxFactory();
> factory.configure(config);
>
> keep this factory around for the life of the app. you only want the
> code above to happen once, not on every request!
>
> this once-per-app initialization is also a good place to create your
> application-scoped toolbox and put that in the servlet context. that
> code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
> and looks roughly like this:
>
> Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
> if (appTools != null &&
> servletContext.getAttribute(Toolbox.class.getName()) == null)
> {
> servletContext.setAttribute(Toolbox.class.getName(), appTools);
> }
>
>
> with that, the application level stuff should be ready to go; now we
> just need to prep some things before every request. so, before you
> create that ViewToolContext in your last example above, use your
> ToolboxFactory and do the following (this code is ripped from
> VelocityView.prepareToolboxes()):
>
> String key = Toolbox.class.getName();
> if (factory.hasTools(Scope.REQUEST)
> && request.getAttribute(key) == null)
> {
> // add request toolbox, if any
> Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
> if (reqTools != null)
> {
> request.setAttribute(key, reqTools);
> }
> }
>
> if (factory.hasTools("session"))
> {
> HttpSession session = request.getSession(true);
> // allow only one thread at a time
> synchronized(factory)
> {
> if (session.getAttribute(key) == null)
> {
> Toolbox sessTools =
> factory.createToolbox("session");
> session.setAttribute(key, sessTools);
> }
> }
> }
>
>
> This creates the Toolbox instances for the current session and request
> and puts them where the ViewToolContext can find them. Once all of
> the above is done, create your ViewToolContext and return that.
>
> i think that should do the trick. sorry this is more complicated that
> i'd hoped. i'll try and whip the VelocityView init code into
> something more forgiving and get a new beta out. Thanks for bringing
> attention to this deficit. :)
>
>
>
> > Thanks again.
> >
> >
> >
> >
> > Charlie
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
On Tue, Apr 8, 2008 at 4:22 PM, Claude Brisson <cl...@renegat.net> wrote:
>
> Le mardi 08 avril 2008 à 15:15 -0700, Nathan Bubna a écrit :
>
> > On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com> wrote:
> > > Ok. I tried and tried and I cannot get the ServletConfig to where I need it
> > > so
> > > I can create a new VelocityView. The best I can get is a ServletContext.
> >
> > That is a bummer. Thank you! Seriously, this exposes a signficant
> > shortcoming in the plans to make it easy to integrate Tools into other
> > frameworks. It also made me realize that i didn't provide proper
> > Filter support either. It needs to be easier to init() a VelocityView
> > (whether with a ServletConfig, FilterConfig or neither). I'll try to
> > set aside some time to fix that this week. It'll mean we need to do
> > another beta, i'm sure, but i think it'll be well worth it.
>
> I noted this fact in http://issues.apache.org/jira/browse/VELTOOLS-94
>
> :-)
>
> It's some code you left apart for some reason...
>
>
> Claude
sorry, i don't think i read that issue carefully the first time, or at
least i wasn't thinking straight. because i apparently didn't think
through the fact that a filter can only get a FilterConfig, not a
ServletConfig. i was in mexico at the time; guess i got a bit too
much sun on Christmas. ;)
anyway, i'll try to address some of these things this week. and
please, feel free to help out. and if you can't, at least keep close
tabs on me. obviously i haven't yet used this with a Filter, and it's
always easier to over/under engineer when doing something you don't
actually need at the moment. extra eyes are appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Claude Brisson <cl...@renegat.net>.
Le mardi 08 avril 2008 à 15:15 -0700, Nathan Bubna a écrit :
> On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com> wrote:
> > Ok. I tried and tried and I cannot get the ServletConfig to where I need it
> > so
> > I can create a new VelocityView. The best I can get is a ServletContext.
>
> That is a bummer. Thank you! Seriously, this exposes a signficant
> shortcoming in the plans to make it easy to integrate Tools into other
> frameworks. It also made me realize that i didn't provide proper
> Filter support either. It needs to be easier to init() a VelocityView
> (whether with a ServletConfig, FilterConfig or neither). I'll try to
> set aside some time to fix that this week. It'll mean we need to do
> another beta, i'm sure, but i think it'll be well worth it.
I noted this fact in http://issues.apache.org/jira/browse/VELTOOLS-94
:-)
It's some code you left apart for some reason...
Claude
> > ------------------------------------------------------------------
> > VelocityView velocityView = new VelocityView( getServletContext() );
> > Context context = velocityView.getContext( request, response );
> > ------------------------------------------------------------------
> >
> > And, looking at the code for VelocityView, when you create a new
> > VelocityView
> > with a ServletContext, it never calls the init(ServletConfig config)
> > method.
> > So, the tools don't get configured. When I do $params.get('thing') it
> > tells me:
> >
> > Request is null. ParameterTool must be initialized first!
>
> Actually, this means the tools did get configured. This just means
> that the tool was never given access to the HttpServletRequest; the
> tools aren't being properly initialized.
>
> You could just precede $params.thing with $params.setRequest($request)
> to make this work, but obviously that shouldn't be necessary and would
> not work for tools who use configure() instead of setters.
>
> > So, I tried it the "standalone" way:
> > ------------------------------------------------------------------
> > ToolManager manager = new ToolManager();
> > if( getToolboxConfigLocation() != null )
> > {
> > manager.configure( getServletContext().getRealPath(
> > getToolboxConfigLocation() ) );
> > }
> > manager.setVelocityEngine( getVelocityEngine() );
> > Context context = manager.createContext();
> > ------------------------------------------------------------------
> >
> > And I get the same result.
>
> As expected. The code above has no knowledge of ServletRequests, so
> it would be unable to tell tools about them.
>
> > One other attempt was made:
> > ------------------------------------------------------------------
> > ViewToolContext context = new ViewToolContext( getVelocityEngine(),
> > request, response,
> > getServletContext() );
> > ------------------------------------------------------------------
> >
> > This time, no errors. But the tools don't work. I see a bunch of
> > $link.setRelative()
> > all over the page. Nothing renders.
>
> That's because the ViewToolContext only knows how to find tools. It
> doesn't create them at all.
>
> >
> > Am I close? Way off? Any help is much appreciated.
> >
>
> Your last example is actually headed in the right direction.
> Unfortunately, since you can't use VelocityView until i fix it, it's a
> little more complicated. Here's the gist, though i'll have to leave
> you to fill in the blanks for the moment:
>
> the first goal is to create a FactoryConfiguration, then configure a
> new ToolboxFactory instance with that config. this may look something
> like this (see VelocityView.configure(ServletConfig, ToolboxFactory)
> for a much more involved example):
>
> FactoryConfiguration config = ConfigurationUtils.getAutoLoaded(); //
> read javadoc on this!
> ToolboxFactory factory = new ToolboxFactory();
> factory.configure(config);
>
> keep this factory around for the life of the app. you only want the
> code above to happen once, not on every request!
>
> this once-per-app initialization is also a good place to create your
> application-scoped toolbox and put that in the servlet context. that
> code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
> and looks roughly like this:
>
> Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
> if (appTools != null &&
> servletContext.getAttribute(Toolbox.class.getName()) == null)
> {
> servletContext.setAttribute(Toolbox.class.getName(), appTools);
> }
>
>
> with that, the application level stuff should be ready to go; now we
> just need to prep some things before every request. so, before you
> create that ViewToolContext in your last example above, use your
> ToolboxFactory and do the following (this code is ripped from
> VelocityView.prepareToolboxes()):
>
> String key = Toolbox.class.getName();
> if (factory.hasTools(Scope.REQUEST)
> && request.getAttribute(key) == null)
> {
> // add request toolbox, if any
> Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
> if (reqTools != null)
> {
> request.setAttribute(key, reqTools);
> }
> }
>
> if (factory.hasTools("session"))
> {
> HttpSession session = request.getSession(true);
> // allow only one thread at a time
> synchronized(factory)
> {
> if (session.getAttribute(key) == null)
> {
> Toolbox sessTools =
> factory.createToolbox("session");
> session.setAttribute(key, sessTools);
> }
> }
> }
>
>
> This creates the Toolbox instances for the current session and request
> and puts them where the ViewToolContext can find them. Once all of
> the above is done, create your ViewToolContext and return that.
>
> i think that should do the trick. sorry this is more complicated that
> i'd hoped. i'll try and whip the VelocityView init code into
> something more forgiving and get a new beta out. Thanks for bringing
> attention to this deficit. :)
>
> > Thanks again.
> >
> >
> >
> >
> > Charlie
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
On Tue, Apr 8, 2008 at 2:10 PM, Charles Harvey III <ch...@alloy.com> wrote:
> Ok. I tried and tried and I cannot get the ServletConfig to where I need it
> so
> I can create a new VelocityView. The best I can get is a ServletContext.
That is a bummer. Thank you! Seriously, this exposes a signficant
shortcoming in the plans to make it easy to integrate Tools into other
frameworks. It also made me realize that i didn't provide proper
Filter support either. It needs to be easier to init() a VelocityView
(whether with a ServletConfig, FilterConfig or neither). I'll try to
set aside some time to fix that this week. It'll mean we need to do
another beta, i'm sure, but i think it'll be well worth it.
> ------------------------------------------------------------------
> VelocityView velocityView = new VelocityView( getServletContext() );
> Context context = velocityView.getContext( request, response );
> ------------------------------------------------------------------
>
> And, looking at the code for VelocityView, when you create a new
> VelocityView
> with a ServletContext, it never calls the init(ServletConfig config)
> method.
> So, the tools don't get configured. When I do $params.get('thing') it
> tells me:
>
> Request is null. ParameterTool must be initialized first!
Actually, this means the tools did get configured. This just means
that the tool was never given access to the HttpServletRequest; the
tools aren't being properly initialized.
You could just precede $params.thing with $params.setRequest($request)
to make this work, but obviously that shouldn't be necessary and would
not work for tools who use configure() instead of setters.
> So, I tried it the "standalone" way:
> ------------------------------------------------------------------
> ToolManager manager = new ToolManager();
> if( getToolboxConfigLocation() != null )
> {
> manager.configure( getServletContext().getRealPath(
> getToolboxConfigLocation() ) );
> }
> manager.setVelocityEngine( getVelocityEngine() );
> Context context = manager.createContext();
> ------------------------------------------------------------------
>
> And I get the same result.
As expected. The code above has no knowledge of ServletRequests, so
it would be unable to tell tools about them.
> One other attempt was made:
> ------------------------------------------------------------------
> ViewToolContext context = new ViewToolContext( getVelocityEngine(),
> request, response,
> getServletContext() );
> ------------------------------------------------------------------
>
> This time, no errors. But the tools don't work. I see a bunch of
> $link.setRelative()
> all over the page. Nothing renders.
That's because the ViewToolContext only knows how to find tools. It
doesn't create them at all.
>
> Am I close? Way off? Any help is much appreciated.
>
Your last example is actually headed in the right direction.
Unfortunately, since you can't use VelocityView until i fix it, it's a
little more complicated. Here's the gist, though i'll have to leave
you to fill in the blanks for the moment:
the first goal is to create a FactoryConfiguration, then configure a
new ToolboxFactory instance with that config. this may look something
like this (see VelocityView.configure(ServletConfig, ToolboxFactory)
for a much more involved example):
FactoryConfiguration config = ConfigurationUtils.getAutoLoaded(); //
read javadoc on this!
ToolboxFactory factory = new ToolboxFactory();
factory.configure(config);
keep this factory around for the life of the app. you only want the
code above to happen once, not on every request!
this once-per-app initialization is also a good place to create your
application-scoped toolbox and put that in the servlet context. that
code is ripped from VelocityView.init(ServletConfig,ToolboxFactory)
and looks roughly like this:
Toolbox appTools = factory.createToolbox(Scope.APPLICATION);
if (appTools != null &&
servletContext.getAttribute(Toolbox.class.getName()) == null)
{
servletContext.setAttribute(Toolbox.class.getName(), appTools);
}
with that, the application level stuff should be ready to go; now we
just need to prep some things before every request. so, before you
create that ViewToolContext in your last example above, use your
ToolboxFactory and do the following (this code is ripped from
VelocityView.prepareToolboxes()):
String key = Toolbox.class.getName();
if (factory.hasTools(Scope.REQUEST)
&& request.getAttribute(key) == null)
{
// add request toolbox, if any
Toolbox reqTools = factory.createToolbox(Scope.REQUEST);
if (reqTools != null)
{
request.setAttribute(key, reqTools);
}
}
if (factory.hasTools("session"))
{
HttpSession session = request.getSession(true);
// allow only one thread at a time
synchronized(factory)
{
if (session.getAttribute(key) == null)
{
Toolbox sessTools =
factory.createToolbox("session");
session.setAttribute(key, sessTools);
}
}
}
This creates the Toolbox instances for the current session and request
and puts them where the ViewToolContext can find them. Once all of
the above is done, create your ViewToolContext and return that.
i think that should do the trick. sorry this is more complicated that
i'd hoped. i'll try and whip the VelocityView init code into
something more forgiving and get a new beta out. Thanks for bringing
attention to this deficit. :)
> Thanks again.
>
>
>
>
> Charlie
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
Ok. I tried and tried and I cannot get the ServletConfig to where I
need it so
I can create a new VelocityView. The best I can get is a ServletContext.
------------------------------------------------------------------
VelocityView velocityView = new VelocityView( getServletContext() );
Context context = velocityView.getContext( request, response );
------------------------------------------------------------------
And, looking at the code for VelocityView, when you create a new
VelocityView
with a ServletContext, it never calls the init(ServletConfig config) method.
So, the tools don't get configured. When I do $params.get('thing') it
tells me:
Request is null. ParameterTool must be initialized first!
So, I tried it the "standalone" way:
------------------------------------------------------------------
ToolManager manager = new ToolManager();
if( getToolboxConfigLocation() != null )
{
manager.configure( getServletContext().getRealPath(
getToolboxConfigLocation() ) );
}
manager.setVelocityEngine( getVelocityEngine() );
Context context = manager.createContext();
------------------------------------------------------------------
And I get the same result.
One other attempt was made:
------------------------------------------------------------------
ViewToolContext context = new ViewToolContext( getVelocityEngine(),
request, response,
getServletContext() );
------------------------------------------------------------------
This time, no errors. But the tools don't work. I see a bunch of
$link.setRelative()
all over the page. Nothing renders.
Am I close? Way off? Any help is much appreciated.
Thanks again.
Charlie
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
Well, I did a bunch more homework on this issue and it is getting much
harder
than I had expected it to. The biggest problem is that Spring actually does
the mergeTemplate() itself. It doesn't leave it for the VVS/VLS.
Here is an example of how Struts would be setup:
----------------------------------------------------------------------------------
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>velocity</servlet-name>
<servlet-class>org.apache.velocity.tools.view.VelocityLayoutServlet</servlet-class>
<init-param>
<param-name>org.apache.velocity.properties</param-name>
<param-value>/WEB-INF/velocity.properties</param-value>
</init-param>
<init-param>
<param-name>org.apache.velocity.toolbox</param-name>
<param-value>/WEB-INF/toolbox.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>velocity</servlet-name>
<url-pattern>*.vm</url-pattern>
</servlet-mapping>
----------------------------------------------------------------------------------
Struts does a request forward to your_page.vm, so the VLS picks up that
call. Spring
doesn't work that way at all, so it makes integration harder.
----------------------------------------------------------------------------------
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
----------------------------------------------------------------------------------
No Velocity in there at all. And, Spring doesn't do a request forward
to the page
you give as a view. It finds the templates internally with a ViewResolver:
http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/servlet/ViewResolver.html
The ViewResolver (in the form of UrlBasedViewResolver) returns the
"viewClass" you
specified, the VelocityView. But this is Springs VelocityView, not
Velocity's VelocityView.
VelocityView does the following:
----------------------------------------------------------------------------------
protected void mergeTemplate(
Template template, Context context, HttpServletResponse
response) throws Exception {
try {
template.merge(context, response.getWriter());
}
catch (MethodInvocationException ex) {
throw new NestedServletException(
"Method invocation failed during rendering of Velocity
view with name '" +
getBeanName() + "': " + ex.getMessage() + "; reference
[" + ex.getReferenceName() +
"], method '" + ex.getMethodName() + "'",
ex.getWrappedThrowable());
}
}
----------------------------------------------------------------------------------
Long way of saying that I cannot get a ServletConfig to pass to
Velocity's VelocityView. :)
The VelocityViewResolver only works with VelocityView. The
VelocityToolboxResolver only
works with VelocityToolboxView. And the VelocityLayoutViewResolver only
works with
VelocityLayoutView. Really quite annoying. So I have to make brand new
classes, not
just extend theirs and replace some methods. And, since I do not have a
ServletConfig,
I have to pull in the tools.xml file another way. The defaults are
great, but I want
to be able to have my tools work as well.
So, what is the best way to get the tools up and running? I know tools
2 is designed
to do just such a thing, but I am not quite up to speed enough to find it.
Thanks again for putting up with such a lengthy dialog.
Charlie
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
On Fri, Apr 4, 2008 at 11:04 AM, Charles Harvey III <ch...@alloy.com> wrote:
>
>
> Nathan Bubna said the following on 4/3/2008 2:29 PM:
>
>
> > On Thu, Apr 3, 2008 at 10:09 AM, Charles Harvey III <ch...@alloy.com>
> wrote:
> >
> >
> > > Well, I tried the drop-in replacement and it failed. It can't find the
> > > template. Not sure why yet. I'm digging through the Spring code to
> see
> > > what it is doing differently than Velocity.
> > >
> > >
> >
> > that's a bummer. and the only thing changed was replacing the tools
> > 1.x jar with the 2.0-beta.jar ?
> >
> >
> Actually, I had moved from spring-1.2.9 to spring-2.5.2. But I did this
> because
> fixes to how spring loads up Velocity were made to the 2.x branch and not
> the 1.x
> branch. All I ever put into the spring config was the resourceLoaderPath
> so I
> have never been sure how spring loads up templates. Total mystery. But,
> for some
> reason, it started failing. It's all action-at-a-distance to me. So, I
> figured
> out how to set the FileResourceLoader and use the ${webapp.root} key to do
> so.
> Now all template loading works on spring-1.2.9 and spring-2.5.2 with
> tools-1.2,
> tools-1.3, tools-1.4 and tools-2.0-beta1. Whoopie!
cool! so, it's using FileResourceLoader but getting the right path
for you? i wonder if this would still work in an unexploded war
deployment?
> >
> > >
> > > So, I also have to look into how the new VelocityTools loads tools and
> how
> > > it is
> > > different from Spring. I'm sure Spring is calling Velocity to do this,
> > > just not sure
> > > where yet. I can setup a VelocityEngine in the configs, but that isn't
> > > where the
> > > tools.xml gets passed.
> > > It has to be in this section of VelocityToolboxView:
> > >
> > >
> ------------------------------------------------------------------------------
> > > // Load a Velocity Tools toolbox, if necessary.
> > > if (getToolboxConfigLocation() != null) {
> > > ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
> > > getServletContext(), getToolboxConfigLocation());
> > > Map toolboxContext = toolboxManager.getToolbox(velocityContext);
> > > velocityContext.setToolbox(toolboxContext);
> > > }
> > >
> > > Can
> > > I simply
> > > replace the ServletToolboxManager with XmlFactoryConfiguration? Is
> > > ToolboxManager
> > > still used?
> > >
> > >
> >
> >
> > no, there's no one-to-one correspondence between the old way and the
> > new way. but if you are willing to hack on Spring (or copy this View
> > class into your own version and hack that), i can probably help. what
> > is the method you got that code from trying to return? is it called
> > per request? what's the lifecycle of the class it belongs to?
> >
> >
> That method returns a org.apache.velocity.context.Context.
>
> --------------------------------------------------------------------------
> protected Context createVelocityContext(
> Map model, HttpServletRequest request, HttpServletResponse response)
> throws Exception {
> // Create a ChainedContext instance.
> ChainedContext velocityContext = new ChainedContext(
> new VelocityContext(model), getVelocityEngine(), request,
> response, getServletContext());
>
> // Load a Velocity Tools toolbox, if necessary.
> if (getToolboxConfigLocation() != null) {
> ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
> getServletContext(), getToolboxConfigLocation());
> Map toolboxContext = toolboxManager.getToolbox(velocityContext);
> velocityContext.setToolbox(toolboxContext);
> }
> return velocityContext;
> }
> --------------------------------------------------------------------------
>
> The class itself is
>
> org.springframework.web.servlet.view.velocity.VelocityToolboxView
>
> http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java?view=markup
>
> which extends
> org.springframework.web.servlet.view.VelocityView:
>
> http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityView.java?view=markup
>
> Either of these two classes is used only once, it is the
> VelocityViewResolver and
> the VelocityLayoutViewResolver that are used on each request.
looks to me like VelocityToolboxView is called per-request, since the
context creation method takes a request and response as parameters.
>
> >
> > ideally, 1 thru 4 are all handled through a VelocityView object that
> > can be stored in the ServletContext and used to both retrieve
> > templates and create tool-supporting contexts. if you can access to
> > the ServletConfig instance in your replacement/hacked Spring MVC
> > classes that do template loading and context creation, then this could
> > be as simple as a call to
> > o.a.v.tools.view.ServletUtils.getVelocityView(servletConfig).
> >
> >
> > as for creating a tool-supporting context, that is more work without
> > being able to use a VelocityView instance, but is still do-able.
> > rather than explain all the options there, i'll wait to see if you
> > need such explanation. the basic idea is to create a
> > FactoryConfiguration object (probably XmlFactoryConfiguration will be
> > most familiar to you). then use that to configure a ToolboxFactory
> > instance. keep the ToolboxFactory around, don't re-init on each
> > request! then have your class do the same work as
> > VelocityView.prepareToolboxes(request) on each request. then create a
> > ViewToolContext instance and use that as the context for that request.
> > looking through the VelocityView methods for configuring the
> > ToolboxFactory might also be enlightening.
> >
> >
> Well, I am going to try replacing Spring's VelocityToolboxView with my own.
> From above
> it looks as though I should be able to get at the ServletConfig if I need
> to. I
> will try figure out how to create a FactoryConfiguration object and then
> setup
> a ToolboxFactory. I'll post if I get it all figured out.
if you can get the ServletConfig, then you can just use a VelocityView
and let it take care of the FactoryConfiguration and ToolboxFactory
for you. just have your context creation method do:
VelocityView view = ServletUtils.getVelocityView(servletConfig);
return view.getContext(request, response);
seriously. with access to the ServletConfig, it's that easy. then
you can tell the VelocityView what to do through your servlet's
init-params, and that's only necessary if you don't like the defaults
and conventions it uses automatically. read the javadoc for it,
especially for the configure(ServletConfig, ToolboxFactory) method.
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/view/VelocityView.html
the VelocityView was designed to make it as easy as possible to
integrate Velocity and VelocityTools into web frameworks. the only
catch is that you need ServletConfig access.
>
>
> Charlie
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
Nathan Bubna said the following on 4/3/2008 2:29 PM:
> On Thu, Apr 3, 2008 at 10:09 AM, Charles Harvey III <ch...@alloy.com> wrote:
>
>> Well, I tried the drop-in replacement and it failed. It can't find the
>> template. Not sure why yet. I'm digging through the Spring code to see
>> what it is doing differently than Velocity.
>>
>
> that's a bummer. and the only thing changed was replacing the tools
> 1.x jar with the 2.0-beta.jar ?
>
Actually, I had moved from spring-1.2.9 to spring-2.5.2. But I did this
because
fixes to how spring loads up Velocity were made to the 2.x branch and
not the 1.x
branch. All I ever put into the spring config was the
resourceLoaderPath so I
have never been sure how spring loads up templates. Total mystery.
But, for some
reason, it started failing. It's all action-at-a-distance to me. So, I
figured
out how to set the FileResourceLoader and use the ${webapp.root} key to
do so.
Now all template loading works on spring-1.2.9 and spring-2.5.2 with
tools-1.2,
tools-1.3, tools-1.4 and tools-2.0-beta1. Whoopie!
>> So, I also have to look into how the new VelocityTools loads tools and how
>> it is
>> different from Spring. I'm sure Spring is calling Velocity to do this,
>> just not sure
>> where yet. I can setup a VelocityEngine in the configs, but that isn't
>> where the
>> tools.xml gets passed.
>> It has to be in this section of VelocityToolboxView:
>>
>> ------------------------------------------------------------------------------
>> // Load a Velocity Tools toolbox, if necessary.
>> if (getToolboxConfigLocation() != null) {
>> ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
>> getServletContext(), getToolboxConfigLocation());
>> Map toolboxContext = toolboxManager.getToolbox(velocityContext);
>> velocityContext.setToolbox(toolboxContext);
>> }
>> Can
>> I simply
>> replace the ServletToolboxManager with XmlFactoryConfiguration? Is
>> ToolboxManager
>> still used?
>>
>
> no, there's no one-to-one correspondence between the old way and the
> new way. but if you are willing to hack on Spring (or copy this View
> class into your own version and hack that), i can probably help. what
> is the method you got that code from trying to return? is it called
> per request? what's the lifecycle of the class it belongs to?
>
That method returns a org.apache.velocity.context.Context.
--------------------------------------------------------------------------
protected Context createVelocityContext(
Map model, HttpServletRequest request, HttpServletResponse
response) throws Exception {
// Create a ChainedContext instance.
ChainedContext velocityContext = new ChainedContext(
new VelocityContext(model), getVelocityEngine(), request,
response, getServletContext());
// Load a Velocity Tools toolbox, if necessary.
if (getToolboxConfigLocation() != null) {
ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
getServletContext(), getToolboxConfigLocation());
Map toolboxContext = toolboxManager.getToolbox(velocityContext);
velocityContext.setToolbox(toolboxContext);
}
return velocityContext;
}
--------------------------------------------------------------------------
The class itself is
org.springframework.web.servlet.view.velocity.VelocityToolboxView
http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java?view=markup
which extends
org.springframework.web.servlet.view.VelocityView:
http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityView.java?view=markup
Either of these two classes is used only once, it is the
VelocityViewResolver and
the VelocityLayoutViewResolver that are used on each request.
> ideally, 1 thru 4 are all handled through a VelocityView object that
> can be stored in the ServletContext and used to both retrieve
> templates and create tool-supporting contexts. if you can access to
> the ServletConfig instance in your replacement/hacked Spring MVC
> classes that do template loading and context creation, then this could
> be as simple as a call to
> o.a.v.tools.view.ServletUtils.getVelocityView(servletConfig).
>
> as for creating a tool-supporting context, that is more work without
> being able to use a VelocityView instance, but is still do-able.
> rather than explain all the options there, i'll wait to see if you
> need such explanation. the basic idea is to create a
> FactoryConfiguration object (probably XmlFactoryConfiguration will be
> most familiar to you). then use that to configure a ToolboxFactory
> instance. keep the ToolboxFactory around, don't re-init on each
> request! then have your class do the same work as
> VelocityView.prepareToolboxes(request) on each request. then create a
> ViewToolContext instance and use that as the context for that request.
> looking through the VelocityView methods for configuring the
> ToolboxFactory might also be enlightening.
>
Well, I am going to try replacing Spring's VelocityToolboxView with my
own. From above
it looks as though I should be able to get at the ServletConfig if I
need to. I
will try figure out how to create a FactoryConfiguration object and then
setup
a ToolboxFactory. I'll post if I get it all figured out.
Charlie
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
On Thu, Apr 3, 2008 at 10:09 AM, Charles Harvey III <ch...@alloy.com> wrote:
> Well, I tried the drop-in replacement and it failed. It can't find the
> template. Not sure why yet. I'm digging through the Spring code to see
> what it is doing differently than Velocity.
that's a bummer. and the only thing changed was replacing the tools
1.x jar with the 2.0-beta.jar ?
> This is what the stack looks like:
>
> ------------------------------------------------------------------------------
> ERROR [2008-04-03 12:40:52,224] (CommonsLoggingLogSystem.java:43) -
> ResourceManager : unable to find resource '/acegilogin.vm' in any resource
> loader.
> ERROR [2008-04-03 12:40:52,228] (StandardWrapperValve.java:253) -
> Servlet.service() for servlet newtimesheets threw exception
> org.apache.velocity.exception.ResourceNotFoundException: Unable to find
> resource '/acegilogin.vm'
> at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452)
> at
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)
> at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)
> at
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1077)
> at
> org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:528)
> at
> org.springframework.web.servlet.view.velocity.VelocityView.getTemplate(VelocityView.java:535)
> at
> org.springframework.web.servlet.view.velocity.VelocityView.getTemplate(VelocityView.java:520)
> at
> org.springframework.web.servlet.view.velocity.VelocityView.checkTemplate(VelocityView.java:293)
> at
> org.springframework.web.servlet.view.velocity.VelocityLayoutView.checkTemplate(VelocityLayoutView.java:122)
>
> ------------------------------------------------------------------------------
odd. i would have expected an issue with tool management, not resource finding.
> How does the VelocityLayoutServlet configure which ResourceManager it will
> use?
> I have been looking at the code and I can't seem to figure that part out.
> Does
> it use the WebappResourceLoader? If so, where does that get configured?
>
> If I mess with the properties and make Velocity use the FileResourceLoader
> and put
> in the whole path to the webapp, it finds the files. Yippie! But, it
> doesn't know
> what to do with the references to the tools. :(
>
> So, I also have to look into how the new VelocityTools loads tools and how
> it is
> different from Spring. I'm sure Spring is calling Velocity to do this,
> just not sure
> where yet. I can setup a VelocityEngine in the configs, but that isn't
> where the
> tools.xml gets passed.
> It has to be in this section of VelocityToolboxView:
>
> ------------------------------------------------------------------------------
> // Load a Velocity Tools toolbox, if necessary.
> if (getToolboxConfigLocation() != null) {
> ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
> getServletContext(), getToolboxConfigLocation());
> Map toolboxContext = toolboxManager.getToolbox(velocityContext);
> velocityContext.setToolbox(toolboxContext);
> }
this is not only the old way of doing things, but not surprisingly, it
uses parts of the old API that just couldn't be transitioned neatly to
the new tool management API. basically, all this code is the same as
in Tools 1.4, but deprecated. so, even if we got this Spring code to
run with the Tools 2 jar, it won't be taking advantage of any new
code. even if we get it to that point, there really isn't much point
until Spring is updated to recognize and support the new tool
management API.
> ------------------------------------------------------------------------------
>
> Is that how the new VelocityTools does it? Or the old VelocityTools?
old way
> Can
> I simply
> replace the ServletToolboxManager with XmlFactoryConfiguration? Is
> ToolboxManager
> still used?
no, there's no one-to-one correspondence between the old way and the
new way. but if you are willing to hack on Spring (or copy this View
class into your own version and hack that), i can probably help. what
is the method you got that code from trying to return? is it called
per request? what's the lifecycle of the class it belongs to?
>
> Sorry, that's a lot of questions in a lot of text. Here is a summary:
>
> 1) If I use the FileResourceManager specifically, it finds templates.
> 2) But, the path to the webapp can change, so I have to find the right way.
definitely!
> 3) Even when I get templates to load, tools do not.
> 4) What is the new implementation for loading the tools so I can write my
> own
> Spring file to replace what they have?
ideally, 1 thru 4 are all handled through a VelocityView object that
can be stored in the ServletContext and used to both retrieve
templates and create tool-supporting contexts. if you can access to
the ServletConfig instance in your replacement/hacked Spring MVC
classes that do template loading and context creation, then this could
be as simple as a call to
o.a.v.tools.view.ServletUtils.getVelocityView(servletConfig).
if not, then things are a bit trickier. the template loading question
is particularly perplexing, as not much has changed there in Tools 2.
all i did was deprecate the o.a.v.tools.view.servlet.WebappLoader and
make it extend its replacement
(o.a.v.tools.view.WebappResourceLoader). i'm really confused as to
why WebappLoader doesn't still work. or perhaps Spring didn't ever
use WebappLoader? how does Spring configure Velocity's resource
loaders?
as for creating a tool-supporting context, that is more work without
being able to use a VelocityView instance, but is still do-able.
rather than explain all the options there, i'll wait to see if you
need such explanation. the basic idea is to create a
FactoryConfiguration object (probably XmlFactoryConfiguration will be
most familiar to you). then use that to configure a ToolboxFactory
instance. keep the ToolboxFactory around, don't re-init on each
request! then have your class do the same work as
VelocityView.prepareToolboxes(request) on each request. then create a
ViewToolContext instance and use that as the context for that request.
looking through the VelocityView methods for configuring the
ToolboxFactory might also be enlightening.
>
>
> Thanks so much.
>
>
> Charlie
>
>
>
>
> Nathan Bubna said the following on 4/2/2008 2:05 PM:
>
>
>
> > hmm. i haven't yet heard or seen any support for Tools 2 from the
> > Spring folks. i would at least just try swapping in the tools 2 jar.
> > if that works, then you might as well just try replacing your
> > toolbox.xml with a tools.xml. i'm really not deeply familiar with how
> > Spring went about integrating toolbox support into their views.
> >
> > i would try bringing this up in their forums. if they aren't already
> > watching Tools 2, it'd be good for them to be aware that its API has
> > stabilized and it's pretty much just waiting on docs, updated examples
> > and maybe further feedback before final release.
> >
> > though Spring is largely SpringSource's baby, it is still open source.
> > so i suppose you could just try writing/contributing a
> > VelocityTools2View or a patch for VelocityToolboxView yourself. i
> > wish i could offer time to help with that, but i've got higher
> > priorities at the moment.
> >
> > feel free to keep up with more specific questions on this. i am also
> > planning to write a doc to help framework devs (like the Spring guys)
> > integrate Tools 2 into their Velocity support.
> >
> > On Wed, Apr 2, 2008 at 10:44 AM, Charles Harvey III <ch...@alloy.com>
> wrote:
> >
> >
> > > Ok. Tougher question. I use Spring as my framework so I never actually
> put
> > > the VelocityLayoutServlet in my web.xml. Instead, I have something
> like so
> > > in my whatever-servlet.xml file:
> > >
> > > <bean id="viewResolver"
> > >
> class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
> > > <property name="viewClass"
> > >
> value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"/>
> > > <property name="cache" value="true"/>
> > > <property name="prefix" value=""/>
> > > <property name="suffix" value=".vm"/>
> > > <property name="exposeRequestAttributes" value="true"/>
> > > <property name="exposeSessionAttributes" value="true"/>
> > > <property name="exposeSpringMacroHelpers" value="true"/>
> > > <property name="layoutUrl" value="/layouts/default_layout.vm"/>
> > > <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
> > > </bean>
> > >
> > > So, what changes? How do I make Spring aware that I am using the new
> > > tools-2.0?
> > > The VelocityToolboxView seems to accommodate the tools-1.2 and
> tools-1.3
> > > when configuring
> > > a tool:
> > >
> > >
> http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java?view=markup
> > >
> > > So do I just need the change the above to point to /WEB-INF/tools.xml
> > > instead of toolbox.xml?
> > >
> > > Does anyone else use Spring? Has anyone tried the new tools setup with
> > > Spring?
> > >
> > > Thanks again.
> > >
> > >
> > > Charlie
> > >
> > >
> > > Nathan Bubna said the following on 4/1/2008 3:16 PM:
> > >
> > >
> > >
> > >
> > >
> > > > yep, that's the idea. as for the init() method, you only need it if
> > > > your tool needs access to the initData for that scope (ServletContext
> > > > for application scope and ViewContext for request or session scope).
> > > > if your tool doesn't need access to any of those things, then it
> > > > doesn't need an init(Object) method.
> > > >
> > > > of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
> > > > things get even easier. :)
> > > >
> > > > On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III
> <ch...@alloy.com>
> > > >
> > > >
> > > wrote:
> > >
> > >
> > > >
> > > >
> > > > > As far as your own tools goes, I want to make sure I've got it
> right:
> > > > >
> > > > > Old:
> > > > > -------------------------------------------------------------
> > > > > public class MyTool implements ViewTool
> > > > > {
> > > > > private String theString;
> > > > >
> > > > > public void init( Object o )
> > > > > {
> > > > > if( !( obj instanceof ViewContext ) )
> > > > > {
> > > > > throw new IllegalArgumentException( "Tool can only be
> > > > > initialized with a ViewContext" );
> > > > > }
> > > > > }
> > > > >
> > > > > public String getTheString()
> > > > > {
> > > > > return "this string comes from a velocity tool";
> > > > > }
> > > > > }
> > > > > -------------------------------------------------------------
> > > > >
> > > > >
> > > > > New:
> > > > > -------------------------------------------------------------
> > > > > public class MyTool
> > > > > {
> > > > > private String theString;
> > > > >
> > > > > public void init( Object o )
> > > > > {
> > > > > if( !( obj instanceof ViewContext ) )
> > > > > {
> > > > > throw new IllegalArgumentException( "Tool can only be
> > > > > initialized with a ViewContext" );
> > > > > }
> > > > > }
> > > > >
> > > > > public String getTheString()
> > > > > {
> > > > > return "this string comes from a velocity tool";
> > > > > }
> > > > > }
> > > > > -------------------------------------------------------------
> > > > >
> > > > >
> > > > > Do I still need the init method? Or can I skip that too?
> > > > >
> > > > > Thanks.
> > > > >
> > > > >
> > > > > Charlie
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Nathan Bubna said the following on 4/1/2008 1:06 PM:
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > > there are some issues with multi-line comments within macros in
> > > > > >
> > > > > >
> > > > >
> > > >
> > > Velocity 1.5
> > >
> > >
> > > >
> > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > if you have written your own custom tools, then you'll find the
> > > > > > ViewTool and Configurable interfaces have been axed in
> VelocityTools
> > > > > > 1.4. just remove the implements declarations for those
> interfaces.
> > > > > > they are unnecessary, as Tools 1.4 will automatically look for
> their
> > > > > > methods in any tool class. if you haven't written any tools of
> your
> > > > > > own, i don't think there's anything to be concerned about.
> > > > > >
> > > > > > that's all i can think of right now, but of course, feel free to
> ask
> > > > > > questions/report problems here.
> > > > > >
> > > > > > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer
> <gh...@weycogroup.com>
> > > > >
> > > > >
> > > >
> > > wrote:
> > >
> > >
> > > >
> > > > > >
> > > > > >> I'm doing maintenance on an app that uses Velocity 1.4 and
> > > > >
> > > > >
> > > >
> > > VelocityTools
> > >
> > >
> > > >
> > > > > >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4.
> Are
> > > > >
> > > > >
> > > >
> > > there
> > >
> > >
> > > >
> > > > > >> any gotchas I should watch out for?
> > > > > >>
> > > > > >> --
> > > > > >> ____________________________________________________________
> > > > > >> Glenn Holmer gholmer@weycogroup.com
> > > > > >> Software Engineer phone: 414-908-1809
> > > > > >> Weyco Group, Inc. fax: 414-908-1601
> > > > > >>
> > > > > >>
> > > > > >>
> > > > >
> > > > >
> > > >
> > > ---------------------------------------------------------------------
> > >
> > >
> > > >
> > > > > >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > > >> For additional commands, e-mail: user-help@velocity.apache.org
> > > > > >>
> > > > > >>
> > > > > >>
> > > > > >
> > > > > >
> ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: user-help@velocity.apache.org
> > >
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
Well, I tried the drop-in replacement and it failed. It can't find the
template. Not sure why yet. I'm digging through the Spring code to see
what it is doing differently than Velocity.
This is what the stack looks like:
------------------------------------------------------------------------------
ERROR [2008-04-03 12:40:52,224] (CommonsLoggingLogSystem.java:43) -
ResourceManager : unable to find resource '/acegilogin.vm' in any
resource loader.
ERROR [2008-04-03 12:40:52,228] (StandardWrapperValve.java:253) -
Servlet.service() for servlet newtimesheets threw exception
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource '/acegilogin.vm'
at
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452)
at
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335)
at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102)
at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1077)
at
org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:528)
at
org.springframework.web.servlet.view.velocity.VelocityView.getTemplate(VelocityView.java:535)
at
org.springframework.web.servlet.view.velocity.VelocityView.getTemplate(VelocityView.java:520)
at
org.springframework.web.servlet.view.velocity.VelocityView.checkTemplate(VelocityView.java:293)
at
org.springframework.web.servlet.view.velocity.VelocityLayoutView.checkTemplate(VelocityLayoutView.java:122)
------------------------------------------------------------------------------
How does the VelocityLayoutServlet configure which ResourceManager it
will use?
I have been looking at the code and I can't seem to figure that part
out. Does
it use the WebappResourceLoader? If so, where does that get configured?
If I mess with the properties and make Velocity use the
FileResourceLoader and put
in the whole path to the webapp, it finds the files. Yippie! But, it
doesn't know
what to do with the references to the tools. :(
So, I also have to look into how the new VelocityTools loads tools and
how it is
different from Spring. I'm sure Spring is calling Velocity to do this,
just not sure
where yet. I can setup a VelocityEngine in the configs, but that isn't
where the
tools.xml gets passed.
It has to be in this section of VelocityToolboxView:
------------------------------------------------------------------------------
// Load a Velocity Tools toolbox, if necessary.
if (getToolboxConfigLocation() != null) {
ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
getServletContext(), getToolboxConfigLocation());
Map toolboxContext = toolboxManager.getToolbox(velocityContext);
velocityContext.setToolbox(toolboxContext);
}
------------------------------------------------------------------------------
Is that how the new VelocityTools does it? Or the old VelocityTools?
Can I simply
replace the ServletToolboxManager with XmlFactoryConfiguration? Is
ToolboxManager
still used?
Sorry, that's a lot of questions in a lot of text. Here is a summary:
1) If I use the FileResourceManager specifically, it finds templates.
2) But, the path to the webapp can change, so I have to find the right way.
3) Even when I get templates to load, tools do not.
4) What is the new implementation for loading the tools so I can write
my own
Spring file to replace what they have?
Thanks so much.
Charlie
Nathan Bubna said the following on 4/2/2008 2:05 PM:
> hmm. i haven't yet heard or seen any support for Tools 2 from the
> Spring folks. i would at least just try swapping in the tools 2 jar.
> if that works, then you might as well just try replacing your
> toolbox.xml with a tools.xml. i'm really not deeply familiar with how
> Spring went about integrating toolbox support into their views.
>
> i would try bringing this up in their forums. if they aren't already
> watching Tools 2, it'd be good for them to be aware that its API has
> stabilized and it's pretty much just waiting on docs, updated examples
> and maybe further feedback before final release.
>
> though Spring is largely SpringSource's baby, it is still open source.
> so i suppose you could just try writing/contributing a
> VelocityTools2View or a patch for VelocityToolboxView yourself. i
> wish i could offer time to help with that, but i've got higher
> priorities at the moment.
>
> feel free to keep up with more specific questions on this. i am also
> planning to write a doc to help framework devs (like the Spring guys)
> integrate Tools 2 into their Velocity support.
>
> On Wed, Apr 2, 2008 at 10:44 AM, Charles Harvey III <ch...@alloy.com> wrote:
>
>> Ok. Tougher question. I use Spring as my framework so I never actually put
>> the VelocityLayoutServlet in my web.xml. Instead, I have something like so
>> in my whatever-servlet.xml file:
>>
>> <bean id="viewResolver"
>> class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
>> <property name="viewClass"
>> value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"/>
>> <property name="cache" value="true"/>
>> <property name="prefix" value=""/>
>> <property name="suffix" value=".vm"/>
>> <property name="exposeRequestAttributes" value="true"/>
>> <property name="exposeSessionAttributes" value="true"/>
>> <property name="exposeSpringMacroHelpers" value="true"/>
>> <property name="layoutUrl" value="/layouts/default_layout.vm"/>
>> <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
>> </bean>
>>
>> So, what changes? How do I make Spring aware that I am using the new
>> tools-2.0?
>> The VelocityToolboxView seems to accommodate the tools-1.2 and tools-1.3
>> when configuring
>> a tool:
>>
>> http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java?view=markup
>>
>> So do I just need the change the above to point to /WEB-INF/tools.xml
>> instead of toolbox.xml?
>>
>> Does anyone else use Spring? Has anyone tried the new tools setup with
>> Spring?
>>
>> Thanks again.
>>
>>
>> Charlie
>>
>>
>> Nathan Bubna said the following on 4/1/2008 3:16 PM:
>>
>>
>>
>>
>>> yep, that's the idea. as for the init() method, you only need it if
>>> your tool needs access to the initData for that scope (ServletContext
>>> for application scope and ViewContext for request or session scope).
>>> if your tool doesn't need access to any of those things, then it
>>> doesn't need an init(Object) method.
>>>
>>> of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
>>> things get even easier. :)
>>>
>>> On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com>
>>>
>> wrote:
>>
>>>
>>>> As far as your own tools goes, I want to make sure I've got it right:
>>>>
>>>> Old:
>>>> -------------------------------------------------------------
>>>> public class MyTool implements ViewTool
>>>> {
>>>> private String theString;
>>>>
>>>> public void init( Object o )
>>>> {
>>>> if( !( obj instanceof ViewContext ) )
>>>> {
>>>> throw new IllegalArgumentException( "Tool can only be
>>>> initialized with a ViewContext" );
>>>> }
>>>> }
>>>>
>>>> public String getTheString()
>>>> {
>>>> return "this string comes from a velocity tool";
>>>> }
>>>> }
>>>> -------------------------------------------------------------
>>>>
>>>>
>>>> New:
>>>> -------------------------------------------------------------
>>>> public class MyTool
>>>> {
>>>> private String theString;
>>>>
>>>> public void init( Object o )
>>>> {
>>>> if( !( obj instanceof ViewContext ) )
>>>> {
>>>> throw new IllegalArgumentException( "Tool can only be
>>>> initialized with a ViewContext" );
>>>> }
>>>> }
>>>>
>>>> public String getTheString()
>>>> {
>>>> return "this string comes from a velocity tool";
>>>> }
>>>> }
>>>> -------------------------------------------------------------
>>>>
>>>>
>>>> Do I still need the init method? Or can I skip that too?
>>>>
>>>> Thanks.
>>>>
>>>>
>>>> Charlie
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Nathan Bubna said the following on 4/1/2008 1:06 PM:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> there are some issues with multi-line comments within macros in
>>>>>
>> Velocity 1.5
>>
>>>>>
>>>> >
>>>> > if you have written your own custom tools, then you'll find the
>>>> > ViewTool and Configurable interfaces have been axed in VelocityTools
>>>> > 1.4. just remove the implements declarations for those interfaces.
>>>> > they are unnecessary, as Tools 1.4 will automatically look for their
>>>> > methods in any tool class. if you haven't written any tools of your
>>>> > own, i don't think there's anything to be concerned about.
>>>> >
>>>> > that's all i can think of right now, but of course, feel free to ask
>>>> > questions/report problems here.
>>>> >
>>>> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com>
>>>>
>> wrote:
>>
>>>> >
>>>> >> I'm doing maintenance on an app that uses Velocity 1.4 and
>>>>
>> VelocityTools
>>
>>>> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are
>>>>
>> there
>>
>>>> >> any gotchas I should watch out for?
>>>> >>
>>>> >> --
>>>> >> ____________________________________________________________
>>>> >> Glenn Holmer gholmer@weycogroup.com
>>>> >> Software Engineer phone: 414-908-1809
>>>> >> Weyco Group, Inc. fax: 414-908-1601
>>>> >>
>>>> >>
>>>> >>
>>>>
>> ---------------------------------------------------------------------
>>
>>>> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>>> >> For additional commands, e-mail: user-help@velocity.apache.org
>>>> >>
>>>> >>
>>>> >>
>>>> >
>>>> > ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>>> > For additional commands, e-mail: user-help@velocity.apache.org
>>>> >
>>>> >
>>>> >
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
hmm. i haven't yet heard or seen any support for Tools 2 from the
Spring folks. i would at least just try swapping in the tools 2 jar.
if that works, then you might as well just try replacing your
toolbox.xml with a tools.xml. i'm really not deeply familiar with how
Spring went about integrating toolbox support into their views.
i would try bringing this up in their forums. if they aren't already
watching Tools 2, it'd be good for them to be aware that its API has
stabilized and it's pretty much just waiting on docs, updated examples
and maybe further feedback before final release.
though Spring is largely SpringSource's baby, it is still open source.
so i suppose you could just try writing/contributing a
VelocityTools2View or a patch for VelocityToolboxView yourself. i
wish i could offer time to help with that, but i've got higher
priorities at the moment.
feel free to keep up with more specific questions on this. i am also
planning to write a doc to help framework devs (like the Spring guys)
integrate Tools 2 into their Velocity support.
On Wed, Apr 2, 2008 at 10:44 AM, Charles Harvey III <ch...@alloy.com> wrote:
> Ok. Tougher question. I use Spring as my framework so I never actually put
> the VelocityLayoutServlet in my web.xml. Instead, I have something like so
> in my whatever-servlet.xml file:
>
> <bean id="viewResolver"
> class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
> <property name="viewClass"
> value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"/>
> <property name="cache" value="true"/>
> <property name="prefix" value=""/>
> <property name="suffix" value=".vm"/>
> <property name="exposeRequestAttributes" value="true"/>
> <property name="exposeSessionAttributes" value="true"/>
> <property name="exposeSpringMacroHelpers" value="true"/>
> <property name="layoutUrl" value="/layouts/default_layout.vm"/>
> <property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
> </bean>
>
> So, what changes? How do I make Spring aware that I am using the new
> tools-2.0?
> The VelocityToolboxView seems to accommodate the tools-1.2 and tools-1.3
> when configuring
> a tool:
>
> http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java?view=markup
>
> So do I just need the change the above to point to /WEB-INF/tools.xml
> instead of toolbox.xml?
>
> Does anyone else use Spring? Has anyone tried the new tools setup with
> Spring?
>
> Thanks again.
>
>
> Charlie
>
>
> Nathan Bubna said the following on 4/1/2008 3:16 PM:
>
>
>
> > yep, that's the idea. as for the init() method, you only need it if
> > your tool needs access to the initData for that scope (ServletContext
> > for application scope and ViewContext for request or session scope).
> > if your tool doesn't need access to any of those things, then it
> > doesn't need an init(Object) method.
> >
> > of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
> > things get even easier. :)
> >
> > On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com>
> wrote:
> >
> >
> > > As far as your own tools goes, I want to make sure I've got it right:
> > >
> > > Old:
> > > -------------------------------------------------------------
> > > public class MyTool implements ViewTool
> > > {
> > > private String theString;
> > >
> > > public void init( Object o )
> > > {
> > > if( !( obj instanceof ViewContext ) )
> > > {
> > > throw new IllegalArgumentException( "Tool can only be
> > > initialized with a ViewContext" );
> > > }
> > > }
> > >
> > > public String getTheString()
> > > {
> > > return "this string comes from a velocity tool";
> > > }
> > > }
> > > -------------------------------------------------------------
> > >
> > >
> > > New:
> > > -------------------------------------------------------------
> > > public class MyTool
> > > {
> > > private String theString;
> > >
> > > public void init( Object o )
> > > {
> > > if( !( obj instanceof ViewContext ) )
> > > {
> > > throw new IllegalArgumentException( "Tool can only be
> > > initialized with a ViewContext" );
> > > }
> > > }
> > >
> > > public String getTheString()
> > > {
> > > return "this string comes from a velocity tool";
> > > }
> > > }
> > > -------------------------------------------------------------
> > >
> > >
> > > Do I still need the init method? Or can I skip that too?
> > >
> > > Thanks.
> > >
> > >
> > > Charlie
> > >
> > >
> > >
> > >
> > >
> > > Nathan Bubna said the following on 4/1/2008 1:06 PM:
> > >
> > >
> > >
> > >
> > > > there are some issues with multi-line comments within macros in
> Velocity 1.5
> > > >
> > > >
> > > >
> > > > if you have written your own custom tools, then you'll find the
> > > > ViewTool and Configurable interfaces have been axed in VelocityTools
> > > > 1.4. just remove the implements declarations for those interfaces.
> > > > they are unnecessary, as Tools 1.4 will automatically look for their
> > > > methods in any tool class. if you haven't written any tools of your
> > > > own, i don't think there's anything to be concerned about.
> > > >
> > > > that's all i can think of right now, but of course, feel free to ask
> > > > questions/report problems here.
> > > >
> > > > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com>
> wrote:
> > > >
> > > >> I'm doing maintenance on an app that uses Velocity 1.4 and
> VelocityTools
> > > >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are
> there
> > > >> any gotchas I should watch out for?
> > > >>
> > > >> --
> > > >> ____________________________________________________________
> > > >> Glenn Holmer gholmer@weycogroup.com
> > > >> Software Engineer phone: 414-908-1809
> > > >> Weyco Group, Inc. fax: 414-908-1601
> > > >>
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > >> For additional commands, e-mail: user-help@velocity.apache.org
> > > >>
> > > >>
> > > >>
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > > For additional commands, e-mail: user-help@velocity.apache.org
> > > >
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > > For additional commands, e-mail: user-help@velocity.apache.org
> > >
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
Ok. Tougher question. I use Spring as my framework so I never actually put
the VelocityLayoutServlet in my web.xml. Instead, I have something like so
in my whatever-servlet.xml file:
<bean id="viewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"/>
<property name="cache" value="true"/>
<property name="prefix" value=""/>
<property name="suffix" value=".vm"/>
<property name="exposeRequestAttributes" value="true"/>
<property name="exposeSessionAttributes" value="true"/>
<property name="exposeSpringMacroHelpers" value="true"/>
<property name="layoutUrl" value="/layouts/default_layout.vm"/>
<property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
</bean>
So, what changes? How do I make Spring aware that I am using the new
tools-2.0?
The VelocityToolboxView seems to accommodate the tools-1.2 and tools-1.3
when configuring
a tool:
http://springframework.cvs.sourceforge.net/springframework/spring/src/org/springframework/web/servlet/view/velocity/VelocityToolboxView.java?view=markup
So do I just need the change the above to point to /WEB-INF/tools.xml
instead of toolbox.xml?
Does anyone else use Spring? Has anyone tried the new tools setup with
Spring?
Thanks again.
Charlie
Nathan Bubna said the following on 4/1/2008 3:16 PM:
> yep, that's the idea. as for the init() method, you only need it if
> your tool needs access to the initData for that scope (ServletContext
> for application scope and ViewContext for request or session scope).
> if your tool doesn't need access to any of those things, then it
> doesn't need an init(Object) method.
>
> of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
> things get even easier. :)
>
> On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com> wrote:
>
>> As far as your own tools goes, I want to make sure I've got it right:
>>
>> Old:
>> -------------------------------------------------------------
>> public class MyTool implements ViewTool
>> {
>> private String theString;
>>
>> public void init( Object o )
>> {
>> if( !( obj instanceof ViewContext ) )
>> {
>> throw new IllegalArgumentException( "Tool can only be
>> initialized with a ViewContext" );
>> }
>> }
>>
>> public String getTheString()
>> {
>> return "this string comes from a velocity tool";
>> }
>> }
>> -------------------------------------------------------------
>>
>>
>> New:
>> -------------------------------------------------------------
>> public class MyTool
>> {
>> private String theString;
>>
>> public void init( Object o )
>> {
>> if( !( obj instanceof ViewContext ) )
>> {
>> throw new IllegalArgumentException( "Tool can only be
>> initialized with a ViewContext" );
>> }
>> }
>>
>> public String getTheString()
>> {
>> return "this string comes from a velocity tool";
>> }
>> }
>> -------------------------------------------------------------
>>
>>
>> Do I still need the init method? Or can I skip that too?
>>
>> Thanks.
>>
>>
>> Charlie
>>
>>
>>
>>
>>
>> Nathan Bubna said the following on 4/1/2008 1:06 PM:
>>
>>
>>
>>> there are some issues with multi-line comments within macros in Velocity 1.5
>>>
>> >
>> > if you have written your own custom tools, then you'll find the
>> > ViewTool and Configurable interfaces have been axed in VelocityTools
>> > 1.4. just remove the implements declarations for those interfaces.
>> > they are unnecessary, as Tools 1.4 will automatically look for their
>> > methods in any tool class. if you haven't written any tools of your
>> > own, i don't think there's anything to be concerned about.
>> >
>> > that's all i can think of right now, but of course, feel free to ask
>> > questions/report problems here.
>> >
>> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
>> >
>> >> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
>> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
>> >> any gotchas I should watch out for?
>> >>
>> >> --
>> >> ____________________________________________________________
>> >> Glenn Holmer gholmer@weycogroup.com
>> >> Software Engineer phone: 414-908-1809
>> >> Weyco Group, Inc. fax: 414-908-1601
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> >> For additional commands, e-mail: user-help@velocity.apache.org
>> >>
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> > For additional commands, e-mail: user-help@velocity.apache.org
>> >
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
yep, that's the idea. as for the init() method, you only need it if
your tool needs access to the initData for that scope (ServletContext
for application scope and ViewContext for request or session scope).
if your tool doesn't need access to any of those things, then it
doesn't need an init(Object) method.
of course, this is all with Tools 1.3 or Tools 1.4. with Tools 2,
things get even easier. :)
On Tue, Apr 1, 2008 at 12:05 PM, Charles Harvey III <ch...@alloy.com> wrote:
> As far as your own tools goes, I want to make sure I've got it right:
>
> Old:
> -------------------------------------------------------------
> public class MyTool implements ViewTool
> {
> private String theString;
>
> public void init( Object o )
> {
> if( !( obj instanceof ViewContext ) )
> {
> throw new IllegalArgumentException( "Tool can only be
> initialized with a ViewContext" );
> }
> }
>
> public String getTheString()
> {
> return "this string comes from a velocity tool";
> }
> }
> -------------------------------------------------------------
>
>
> New:
> -------------------------------------------------------------
> public class MyTool
> {
> private String theString;
>
> public void init( Object o )
> {
> if( !( obj instanceof ViewContext ) )
> {
> throw new IllegalArgumentException( "Tool can only be
> initialized with a ViewContext" );
> }
> }
>
> public String getTheString()
> {
> return "this string comes from a velocity tool";
> }
> }
> -------------------------------------------------------------
>
>
> Do I still need the init method? Or can I skip that too?
>
> Thanks.
>
>
> Charlie
>
>
>
>
>
> Nathan Bubna said the following on 4/1/2008 1:06 PM:
>
>
> > there are some issues with multi-line comments within macros in Velocity 1.5
> >
> > if you have written your own custom tools, then you'll find the
> > ViewTool and Configurable interfaces have been axed in VelocityTools
> > 1.4. just remove the implements declarations for those interfaces.
> > they are unnecessary, as Tools 1.4 will automatically look for their
> > methods in any tool class. if you haven't written any tools of your
> > own, i don't think there's anything to be concerned about.
> >
> > that's all i can think of right now, but of course, feel free to ask
> > questions/report problems here.
> >
> > On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
> >
> >> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
> >> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
> >> any gotchas I should watch out for?
> >>
> >> --
> >> ____________________________________________________________
> >> Glenn Holmer gholmer@weycogroup.com
> >> Software Engineer phone: 414-908-1809
> >> Weyco Group, Inc. fax: 414-908-1601
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> >> For additional commands, e-mail: user-help@velocity.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Charles Harvey III <ch...@alloy.com>.
As far as your own tools goes, I want to make sure I've got it right:
Old:
-------------------------------------------------------------
public class MyTool implements ViewTool
{
private String theString;
public void init( Object o )
{
if( !( obj instanceof ViewContext ) )
{
throw new IllegalArgumentException( "Tool can only be
initialized with a ViewContext" );
}
}
public String getTheString()
{
return "this string comes from a velocity tool";
}
}
-------------------------------------------------------------
New:
-------------------------------------------------------------
public class MyTool
{
private String theString;
public void init( Object o )
{
if( !( obj instanceof ViewContext ) )
{
throw new IllegalArgumentException( "Tool can only be
initialized with a ViewContext" );
}
}
public String getTheString()
{
return "this string comes from a velocity tool";
}
}
-------------------------------------------------------------
Do I still need the init method? Or can I skip that too?
Thanks.
Charlie
Nathan Bubna said the following on 4/1/2008 1:06 PM:
> there are some issues with multi-line comments within macros in Velocity 1.5
>
> if you have written your own custom tools, then you'll find the
> ViewTool and Configurable interfaces have been axed in VelocityTools
> 1.4. just remove the implements declarations for those interfaces.
> they are unnecessary, as Tools 1.4 will automatically look for their
> methods in any tool class. if you haven't written any tools of your
> own, i don't think there's anything to be concerned about.
>
> that's all i can think of right now, but of course, feel free to ask
> questions/report problems here.
>
> On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
>
>> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
>> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
>> any gotchas I should watch out for?
>>
>> --
>> ____________________________________________________________
>> Glenn Holmer gholmer@weycogroup.com
>> Software Engineer phone: 414-908-1809
>> Weyco Group, Inc. fax: 414-908-1601
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: upgrading
Posted by Nathan Bubna <nb...@gmail.com>.
there are some issues with multi-line comments within macros in Velocity 1.5
if you have written your own custom tools, then you'll find the
ViewTool and Configurable interfaces have been axed in VelocityTools
1.4. just remove the implements declarations for those interfaces.
they are unnecessary, as Tools 1.4 will automatically look for their
methods in any tool class. if you haven't written any tools of your
own, i don't think there's anything to be concerned about.
that's all i can think of right now, but of course, feel free to ask
questions/report problems here.
On Tue, Apr 1, 2008 at 8:49 AM, Glenn Holmer <gh...@weycogroup.com> wrote:
> I'm doing maintenance on an app that uses Velocity 1.4 and VelocityTools
> 1.1, and would like to upgrade to Velocity 1.5 and tools 1.4. Are there
> any gotchas I should watch out for?
>
> --
> ____________________________________________________________
> Glenn Holmer gholmer@weycogroup.com
> Software Engineer phone: 414-908-1809
> Weyco Group, Inc. fax: 414-908-1601
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org