Citat Nathan Bubna <[EMAIL PROTECTED]>:

> On 12/6/06, Martin Tilsted <[EMAIL PROTECTED]> wrote:
> > Citat Will Glass-Husain <[EMAIL PROTECTED]>:
> >
> > > Martin,
> > >
> > > If at all possible, use VelocityViewServlet from the Velocity Tools
> > > project.  Although it works similarly It's better supported.  (we've
> > > deprecated VelocityServlet in the latest release).
> >
> > With the latest release, I asume you mean 1.5 which is still in beta.
> >
> > But I don't understand how VelocityViewServlet, works similary to
> > VelocityServlet. Let my try if I understand VelocityViewServlet correct.
> >
> > 1: I don't have a class for each template. Insted I populate a View with
> > 'tool objects' that are always available for all templates to use.
>
> you don't need a class for each template with the VelocityServlet
> either.  and you don't have to use tools or the toolbox support with
> the VelocityViewServlet if you don't want to.

So I can just use VelocityViewServlet as an (almost) dropin for VelocityServle?

>
> > 2: My classes don't have to extend VelocityViewServlet
>
> what classes are we talking about?

My current setup is that for each page, I have a class which extend
VelocityServlet. It handles the request, populate the Context and then load the
template for that page. And I like it that way(For my current project atleast)
:}

> > 4:  It seems like there need to be a way to force a tool to be loaded on a
> give
> > page, even if not used by the template. I don't vant my authorization to
> depend
> > on whenever my SomePage.vm file remember to call the correct method in one
> of my
> > tools. A combination of push and pull would be really cool :}
>
> You can always sub-class the VelocityViewServlet to push data instead
> of always pulling it, but most frameworks support push very well too.

Oh so it is posible. Someone might want to update the documentation at
http://jakarta.apache.org/velocity/tools/view/
Because that description really make it sound VelocityViewServlet is pull only.

>
> > Oh, but that was just me trying to understand the pull method. Not my
> current
> > problem. That follow below :}
> >
> >
> > >
> > > Having said that, you need to override the loadConfiguration method to
> > > set Velocity properties.
> >
> > And once I have overridden the loadConfiguration in my MyGallery class what
> am I
> > suposed to do in the overloaded method?
> >
> > I tried to add
> >
> >         protected java.util.Properties
> loadConfiguration(javax.servlet.ServletConfig
> > arg0) throws java.io.IOException, java.io.FileNotFoundException {
> >                 java.util.Properties p=super.loadConfiguration(arg0);
> >
> >
> p.setProperty("directive.foreach.counter.initial.value","0");
> >                 return p;
> >         }
> >
> > But it still start counting with 1.
>
> are you sure this method is being called?

Yes I tried to throw an Error and it was thrown. So it is loaded. But now I have
made velocity read my property file, and that is the best solution :}

> this looks like it should
> work for the VelocityServlet.  of course, using velocity.properties
> should work too (unless you are deploying your application as an
> unexploded war.  VelocityServlet typically fails to load properties in
> such a case because it tries to load it via
> servletContext.getRealPath(file) which doesn't work in all deployment
> scenarios.  this is another area where the VelocityViewServlet is
> superior.

I managed to make it work. The problem was that I was using velocity-dep-1.4.jar
located in apache-tomcat-5.5.17/common/lib
This did for some reason not read my properties file.

So now I have copied velocity-1.4.jar directly to my webapps/twgc/WEB-INF/lib/
directory and now it's working. (twgc is the website)

The really funny thing is that my velocity-1.4.jar depend on
velocity-dep-1.4.jar for some files. But things are working now :}

Martin


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

Reply via email to