Spring 1.2.8 and Velocity Tools 1.2 (I tried 1.3 and there were loads of
problems
so I will make that move later).
I put a log statement into the constructor and it gets called 8 times. See,
with Spring, I load a DispatcherServlet for different servlet paths.
Each one
of those has its own toolbox (not sure if that's good or bad or
indifferent).
So, 8 toolboxes get loaded up so I see logs for 8 AlloyBrowserSnifferTool
constructors. But none for init().
Very strange indeed.
Charlie
Nathan Bubna said the following on 3/20/2007 5:26 PM:
That's really odd. Especially if the other tools are being init'ed.
I'm not sure what would cause this, as i don't use Spring's Velocity
support much. But, out of curiousity, what version of Spring and
what version of VelocityTools?
Also, try putting a log out into your local copy of
BrowserSnifferTool's default constructor just to make sure that it is
that class that is being instantiated.
On 3/20/07, Charles Harvey III <[EMAIL PROTECTED]> wrote:
Hello.
This might be a question for the Spring list but I will try here first.
It seems that the BrowserSnifferTool.init( Object o ) method is not
getting
called upon the start of my webapp. So when I do $browser.getIe() I get
a NullPointerException. This is because the userAgent is never set in
the init() method.
Here is the setup:
web.xml:
----------------------------------------------------------------------------
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>
----------------------------------------------------------------------------
app-servlet.xml:
----------------------------------------------------------------------------
<bean id="viewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.velocity.VelocityLayoutView"/>
<property name="cache" value="true"/>
<property name="prefix" value="/app"/>
<property name="suffix" value=".vm"/>
<property name="exposeRequestAttributes" value="true"/>
<property name="exposeSessionAttributes" value="true"/>
<property name="exposeSpringMacroHelpers" value="true"/>
<property name="layoutUrl" value="/layouts/default_layout.vm"/>
<property name="toolboxConfigLocation" value="/WEB-INF/toolbox.xml"/>
</bean>
----------------------------------------------------------------------------
toolbox.xml:
----------------------------------------------------------------------------
<tool>
<key>browser</key>
<scope>request</scope>
<class>org.apache.velocity.tools.view.tools.BrowserSnifferTool</class>
</tool>
----------------------------------------------------------------------------
Every other tool seems to work but this one. I don't get it. There
is a:
private String userAgent = null; in BrowserSnifferTool and it gets
called by
almost every method. Thing is, it stays null because init( Object o )
is never
called. I copied BrowserSnifferTool to my project and put log
statements into
the init() method, just to make sure it was getting called - no dice.
Any ideas on this are much appreciated.
Charlie
---------------------------------------------------------------------
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]