velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Rishel" <illu...@gmail.com>
Subject Re: Getting a velocity engine in Spring
Date Thu, 24 Aug 2006 01:02:20 GMT
Just what I needed Charlie, thanks!

I have it working to the point of calling MyVelocityView,
so hopefully just footwork from here.

You illustrated a number of configuration properties
that I haven't seen documentation for (I see the properties
mentioned in the class javadocs, but not the xml
configuration documentation). Is there a place where I
can find such docs?

Again, thanksX1000!

Bill


On 8/22/06, Charles Harvey III <charlieh@alloy.com> wrote:
> Bill,
> I have been using Spring with Velocity for quite some time now.  But I
> always
> use one of the out-of-the-box solutions to render templates.  I even
> made the
> Spring folks add the VelocityLayoutView because VelocityToolboxView and
> VelocityView
> did not work the same as the VelocityLayoutServlet from Velocity.
>
> So, here is what I think you will have as a setup, based on your e-mail:
>
> applicationContext.xml:
> ---------------------------------------------------------------------
> <bean id="velocityConfigurer"
> class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
>   <property name="resourceLoaderPath" value=""/>
>   <property name="velocityProperties">
>     <props>
>       <prop key="velocimacro.library">/includes/macros.vm</prop>
>       <prop key="velocimacro.library.autoreload">true</prop>
>       <prop key="velocimacro.permissions.allow.inline">true</prop>
>       <prop
> key="velocimacro.permissions.allow.inline.to.replace.global">false</prop>
>       <prop
> key="velocimacro.permissions.allow.inline.local.scope">false</prop>
>       <prop key="velocimacro.context.localscope">false</prop>
>       <prop
> key="tools.view.servlet.error.template">/includes/layout_error.vm</prop>
>       <prop key="tools.view.servlet.layout.directory">/includes/</prop>
>       <prop
> key="resource.manager.class">org.apache.velocity.runtime.resource.ResourceManagerImpl</prop>
>       <prop
> key="resource.manager.cache.class">org.apache.velocity.runtime.resource.ResourceCacheImpl</prop>
>     </props>
>   </property>
> </bean>
>
> <!-- VIEW RESOLVER (Velocity) -->
> <bean id="viewResolver"
> class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
>   <property name="viewClass"
> value="org.springframework.web.servlet.view.velocity.VelocityView"/>
>   <property name="cache" value="true"/>
>   <property name="prefix" value="/WEB-INF/velocity"/>
>   <property name="suffix" value=".vm"/>
>   <property name="exposeRequestAttributes" value="true"/>
>   <property name="exposeSessionAttributes" value="true"/>
>   <property name="exposeSpringMacroHelpers" value="true"/>
> </bean>
> ---------------------------------------------------------------------
>
> I am quite sure that the only thing you will have to change is the
> "viewClass"
> in the <bean id="viewResolver">.  Change the VelocityView to
> MyVelocityView or
> whatever your class is called.  Take a look at the code in the Spring
> sources.
> Take note of VelocityToolboxView and VelocityLayoutView because both of
> those
> classes subclass VelocityView and make small changes to how a template is
> rendered.
>
> Good luck, let me know if this helps.
>
>
>
> Charlie
>
>
>
>
>
> Bill Rishel said the following on 8/21/2006 6:15 PM:
> > Within Struts I've been using a velocity engine from within a subclass of
> > VelocityViewServlet with which I am able to call
> > evaluate(Context context, java.io.Writer out, java.lang.String logTag,
> > java.lang.String instring)
> > to render the vtl in the 'instring'. Because I am doing my own
> > preprocessing before
> > that call and possibly after I need that kind of fine grained control
> > of the
> > vtl rendering.
> >
> > I am moving now to Spring, which gives me some important features,
> > but haven't been able to figure out how to do the "hand rendering" of
> > the vtl within a Spring controller. Any suggestions on how to do that?
> >
> > Bill Rishel
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>

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


Mime
View raw message