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.
2: My classes don't have to extend VelocityViewServlet
what classes are we talking about?
3: How do I take the result of a form submit, and write it to a database. Since
there is no class that is always called for a given page, does it mean that if
I submit a form to RecieveForm, it is the responsible of the RecieveForm.vm to
call a method, which can handle the incomming form data?
that's one way you can do it, but there are many other ways.
including some much easier ones. what sort of web application are
you developing? if it is likely to have many forms and be more of a
read & write app, rather than just a dynamic read-only site, then i
would highly recommend you use a proper web framework like Struts or
Click. if there is only a little bit of database updating/writing
going on, then you might check out a tool like Velosurf to handle it.
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, 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? 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.
> WILL
>
> On 12/5/06, Martin Tilsted <[EMAIL PROTECTED]> wrote:
> > Some basic information:
> > I am using velocity 1.4 with Tomcat 5.5.17, and all my servlets extend the
> class
> > org.apache.velocity.servlet.VelocityServlet
> >
> > And that part is working fine.
> >
> > But now I am trying to set the directive.foreach.counter.initial.value to 0
> so
> > my loop count begin with 0 insted of 1. And I just can't get it to work.
> >
> > I started with something simple, trying to do a
> >
>
org.apache.velocity.app.Velocity.setProperty("directive.foreach.counter.initial.value","0");
> > in my servlet initialization code. But that had no effect. So I tried
> >
>
Vorg.apache.velocity.app.Velocity.setProperty("directive.foreach.counter.initial.value",new
> > Integer(0));
> >
> > But that did not work either. The value of
> > directive.foreach.counter.initial.value is still 1.
> >
> > Is this because the org.apache.velocity.app.Velocity class is meant to be
> used
> > in stand alone applicatinos only?
> >
> > Well then I tried to make a velocity.properties file.
> > A cut from my web.xml file is
> >
> > <servlet>
> > <init-param>
> > <!-- Should this not be org.apache.velocity.properties -->
> > <param-name>properties</param-name>
> > <param-value>/velocity.properties</param-value>
> > </init-param>
> > <servlet-name>MyGallery</servlet-name>
> > <servlet-class>twgc.MyGallery</servlet-class>
> > </servlet>
> >
> > But it still seems like velocity don't pickup my velocity.properties file.
> All
> > the log say about properties are
> >
> > [info] Default Properties File:
> > org/apache/velocity/runtime/defaults/velocity.properties
> >
> > So no error message, or anything that indicate it have loaded my properties
> > file. So what am I doing wrong?
> >
> > Martin Tilsted
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> [EMAIL PROTECTED]
> www.forio.com
>
> ---------------------------------------------------------------------
> 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]