velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: Is it possible to load toolboxes from multiple toolbox.xml files?
Date Thu, 19 Feb 2009 15:14:58 GMT
Yeah, you can do this.  And there are several different ways it can be
done.  One is to use a custom VelocityView class.

public MyVelocityView extends VelocityView {

  @Override
  protected void init(JeeConfig config) {
    super.init(config);
    String otherConfig = config.getInitParameter("user.toolbox.path");
    if (otherConfig != null) {
      FactoryConfiguration factoryConfig = getConfiguration(otherConfig, true);
      configure(factoryConfig);
    }
  }

}

You can call the configure(FactoryConfig) method as many times as you
like, of course.   Once you have your custom VelocityView class, you
can tell the VelocityViewServlet to use it by adding this to your
init-params:

<init-param>
  <param-name>org.apache.velocity.tools.view.class</param-name>
  <param-value>com.foo.MyVelocityView</param-value>
</init-param>

Like i said, there are other ways, but this was the first that came to
mind.  In general, the methods that are your friends are
velocityView.configure(FactoryConfiguration) and
ServletUtils.getConfiguration(String,ServletContext).

On Wed, Feb 18, 2009 at 10:14 PM, bluejoe <bluejoe@sdb.cnic.cn> wrote:
> Hi,
>
> With VelocityView, I want to load toolboxes from multiple files, for example, from both
'/WEB-INF/toolbox.xml' and '/WEB-INF/toolbox.user.xml', the later file maybe be provided by
other developers instead of myself. But I have no idea how to do because it seems that VelocityViewServlet
only use '/WEB-INF/toolbox.xml' as input.
>
> Can anyone give me any advice?
>
> Thanks for any help.

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


Mime
View raw message