velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Thelian <Martin.Thel...@gmx.at>
Subject Re: Tools 2.0 / VelocityLayoutServlet / loadConfiguration
Date Fri, 04 Jul 2008 05:04:27 GMT
Hi,

I'd like to thank you too for the quick reply and support. Allowing to 
provide custom velocityviews would be great. I've already tried to do 
that with version 2.0alpha1 but had not found a way to configure 
velocity to use it.

Regards,
Martin

Nathan Bubna wrote:
> Hi Martin,
>
> You're right.  There is no good replacement for this yet.  Thanks for
> catching that!  I have some unchecked-in code for allowing people to
> easily tell VelocityViewServlet (and kin) to use a custom subclass of
> VelocityView.  I think i'll run some tests and check that in.  Once
> that feature is available, you will want to create a class like this:
>
> package org.com;
>
> import org.apache.velocity.tools.view.VelocityView;
> import org.apache.velocity.tools.view.JeeConfig;
> import org.apache.velocity.app.VelocityEngine;
>
> public class MyVelocityView extends VelocityView {
>
>   public MyVelocityView(JeeConfig config) {
>      super(config);
>   }
>
>   protected void configure(JeeConfig config, VelocityEngine engine) {
>      super.configure(config, engine);
>      // i leave it to you to determine where the customUrl value comes from :)
>      engine.setProperty("url.resource.loader.root", this.customUrl);
>   }
> }
>
> and add this to your VelocityLayoutServlet's web.xml config:
>
>     <init-param>
>       <param-name>org.apache.velocity.tools.view.class</param-name>
>       <param-value>org.com.MyVelocityView</param-value>
>     </init-param>
>
> And i think that should do the trick.  Of course, first i have to
> clean up and check in the code that lets you subclass VelocityView
> like this.
>
> And really, thank you for catching this before 2.0 final is released!
> This is exactly the kind of feedback we need to make sure people can
> migrate from 1.x.
>
> On Thu, Jul 3, 2008 at 9:49 AM, Martin Thelian wrote:
>   
>> Hi,
>>
>> I'd link to migrate from Velocity tools version 1.3 to version 2.0. With
>> version 1.3 it was possible to change the root-URL of the URLResourceLoader
>> by simply overwriting the method "loadConfiguration(ServletConfig config).",
>> e.g.
>>     
>>>    @Override
>>>    protected ExtendedProperties loadConfiguration(ServletConfig config)
>>> throws IOException {
>>>        ExtendedProperties props = super.loadConfiguration(config);
>>>        props.addProperty("url.resource.loader.root",this.customURL);
>>>        return props;
>>>    }
>>>       
>> With version 2.0 this seems not to be possible anymore. What is the best way
>> to do the same with the new tools version?
>>
>> Thanks.
>> Martin
>>     


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


Mime
View raw message