velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai <shinobu.ka...@gmail.com>
Subject Re: how to inherit ServletToolboxManager?
Date Wed, 05 Jan 2005 12:33:45 GMT
Hi Sato,

> I'm using VelocityView and am very happy it's much easier creating
> dynamic HTML than JSP and custom tags.

Agreed.  :)

> Now I need to use some my own implementation of ServletToolboxRuleSet
> (which is in "org.apache.velocity.tools.view.servlet" package),
> so I tried to extend ServletToolboxManager to overrride "getRuleSet()"
> method in it. But I couldn't because ServletToolboxManager is singleton
> and its only constructor is private.

It is so easy to change the constructor protected.  ;)

> ServletToolboxManager source (VelocityTools 1.1) is like this:
> ===

## snip

> and I made subclass like this (it's bad solution. it fails to compile...):
> ===
> public class MyServletToolboxManger extends ServletToolboxManager {
>  public static synchronized ServletToolboxManger getInstance(
>    ServletContext servlet,
>    String toolboxFile) {
>    ...
>  }
>  protected RuleSet getRuleSet() { /* return my own RuleSet */ }
> }
> ===
> 
> If any good idea to extend ServletToolboxManager, please could you
> tell me?

Hacking VelocityViewServlet#initToolbox()?  Actually, I think it might
be nice if you could configure the RuleSet via init-param.

Best regards,
-- Shinobu

--
Shinobu "Kawai" Yoshida <shinobu.kawai@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message