I haven't used Spring with Velocity, so i can't help much. You may have more luck on the spring forums. That said, here's a few thoughts that may or may not help.
On 1/22/07, darrowj <[EMAIL PROTECTED]> wrote:
I have a client that wants to be able to display a totally different set of Velocity templates based on the Domain a user enters a web app. So completely different presentation layer but the same controllers, services, and database. I've created an Interceptor that finds the domain and the domainDirectory where the velocity templates will live for said domain and puts it in session for a given user. I could do something like return 'new ModelAndView(domainDirectory + "/home");' but I would rather not have to edit all of my controllers if possible because I think things will quickly change.
Quickly changing things are difficult, but Spring's DI should help. You could always create a "pathfinder" type object that your controllers would use to find the right path, then inject the pathfinder into your controllers, and just change the pathfinder whenever "things change".
I'd like to dynamically change the Velocity resourceLoaderPath somehow based on the domain a user uses to get to the web application.
That may be both difficult and unwise if Spring directly feeds that path to the resourceLoader that Velocity's runtime is using. Changing it might mean re-initializing Velocity every time you want to change the path. That would cause very poor performance.
I've done a lot of searching and read that the VelocityEngineFactoryBean may be what I need but cannot make it work. In my appname-servlet.xml I have the following: <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.veloci ty.VelocityConfigurer"> <property name="resourceLoaderPath"> <value>WEB-INF/velocity</value> </property> </bean> <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEng ineFactoryBean"> <property name="velocityProperties"> <props> <prop key="resource.loader">class</prop> <prop key="class.resource.loader.class">org.apache.veloc ity.runtime.resource.loader.ClasspathResourceLoade r</prop> </props> </property> </bean> <bean id="domainInterceptor" class="com.somedomain.web.DomainInterceptor"> <property name="communityContextService"> <ref bean="communityContextService"/> </property> <property name="velocityEngine"> <ref bean="velocityEngine"/> </property> </bean> This does not work as my Interceptor complains of an setter error and I've reviewed and cannot resolve the problem. My real question is can the Velocity resourceLoaderPath be set dynamically by your web application? If so am I on the right track? -- View this message in context: http://www.nabble.com/Dynamic-Velocity-resourceLoaderPath-in-Spring--tf3061673.html#a8513803 Sent from the Velocity - User mailing list archive at Nabble.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]
