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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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                          [EMAIL PROTECTED]
>  >>  Software Engineer                        phone: 414-908-1809
>  >>  Weyco Group, Inc.                          fax: 414-908-1601
>  >>
>  >>
>  >>  ---------------------------------------------------------------------
>  >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  >>  For additional commands, e-mail: [EMAIL PROTECTED]
>  >>
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to