You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jack Holt <ja...@gmail.com> on 2005/05/13 16:58:41 UTC
Passing data into a Velocity Template from a Spring Controller
Can anyone tell me or point me to something that explains how to pass
data from a Spring controller to a Velocity Template? I know about
using Velocity View Resolvers. I have successfully called Velocity
Views from Spring Controllers but I'm unable to make the connection
between a Spring model and a Velocity context.
I've read all the documentation I can find on using Velocity with
Spring (for instance the section starting on page 139 of the Spring
Reference Manual).
How do I make the connection?
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Passing data into a Velocity Template from a Spring Controller
Posted by Jack Holt <ja...@gmail.com>.
Great! I look forward to seeing the Wiki because I plan to use the
same mix of Spring, Velocity and Hibernate myself!
On 5/13/05, Will Glass-Husain <wg...@forio.com> wrote:
> Nice idea to build a wiki page. We need to link Spring into the Wiki
> PoweredByVelocity page under Frameworks, too - it's now a very prominent
> example.
>
> I'm in the middle of a project combining Spring, Velocity, and Hibernate.
> It's a nice combination.
>
> WILL
>
> ----- Original Message -----
> From: "Shinobu Kawai" <sh...@gmail.com>
> To: "Velocity Users List" <ve...@jakarta.apache.org>
> Sent: Friday, May 13, 2005 11:28 AM
> Subject: Re: Passing data into a Velocity Template from a Spring Controller
>
> TWIMC,
>
> > 1) follow the Spring mvc tutorial (which makes it happen for jsps) and
> > then modify it for velocity (basically just by changing your view
> > resolver as per the ch 13 (views) of the spring ref.)
> > http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html
>
> I just started creating a supplemental document for Velocity here:
> http://wiki.apache.org/jakarta-velocity/VelocityAndSpringStepByStep
>
> Best regards,
> -- Shinobu
>
> --
> Shinobu Kawai <sh...@gmail.com>
>
> ---------------------------------------------------------------------
> 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
Re: Passing data into a Velocity Template from a Spring Controller
Posted by Will Glass-Husain <wg...@forio.com>.
Nice idea to build a wiki page. We need to link Spring into the Wiki
PoweredByVelocity page under Frameworks, too - it's now a very prominent
example.
I'm in the middle of a project combining Spring, Velocity, and Hibernate.
It's a nice combination.
WILL
----- Original Message -----
From: "Shinobu Kawai" <sh...@gmail.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Friday, May 13, 2005 11:28 AM
Subject: Re: Passing data into a Velocity Template from a Spring Controller
TWIMC,
> 1) follow the Spring mvc tutorial (which makes it happen for jsps) and
> then modify it for velocity (basically just by changing your view
> resolver as per the ch 13 (views) of the spring ref.)
> http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html
I just started creating a supplemental document for Velocity here:
http://wiki.apache.org/jakarta-velocity/VelocityAndSpringStepByStep
Best regards,
-- Shinobu
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
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
Re: Passing data into a Velocity Template from a Spring Controller
Posted by Shinobu Kawai <sh...@gmail.com>.
TWIMC,
> 1) follow the Spring mvc tutorial (which makes it happen for jsps) and
> then modify it for velocity (basically just by changing your view
> resolver as per the ch 13 (views) of the spring ref.)
> http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html
I just started creating a supplemental document for Velocity here:
http://wiki.apache.org/jakarta-velocity/VelocityAndSpringStepByStep
Best regards,
-- Shinobu
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Passing data into a Velocity Template from a Spring Controller
Posted by Robert Koberg <ro...@koberg.com>.
Tim Diggins wrote:
> But I would recommend following through the spring mvc tutorial (except
> for the last page on db-stuff which has lots of locking problems... at
> least when launched from within eclipse ...).
It seems the tutorial was written for an older version of hsqldb (not
that I know much about it...). I put:
COMMIT;
SHUTDOWN;
before the sql end tag in the following Ant tasks from the tutorial:
createTables, dropTables and loadData
best,
-Rob
>
> Tim
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Help using velocity tools
Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Wayne,
> I need to be able to do some date processing in my macros, I saw the
> velocitytools stuff and it will do what I need, but how do I access/use
> the tools in my macros?
Just put it in the Context.
http://jakarta.apache.org/velocity/developer-guide.html#The%20Context
Or if you're using VelocityViewServlet, put it in the toolbox.xml.
http://jakarta.apache.org/velocity/tools/view/index.html#Toolbox%20Configuration
Best regards,
-- Shinobu
--
Shinobu Kawai <sh...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Help using velocity tools
Posted by Wayne Andersen <wa...@clima-tech.com>.
I need to be able to do some date processing in my macros, I saw the
velocitytools stuff and it will do what I need, but how do I access/use
the tools in my macros?
Wayne L Andersen
System Administrator
Clima-Tech Corporation
208-947-1849
Re: Passing data into a Velocity Template from a Spring Controller
Posted by Jack Holt <ja...@gmail.com>.
Thanks. It works just like you said. Of course, previously I had
already tried exactly what you said, but it didn't work. I guess I
needed to reload the app in the server and had neglected to.
On 5/13/05, Tim Diggins <su...@red56.co.uk> wrote:
> Hi Jack -
>
> I found the following two bits of reference useful in getting started
> with spring :
>
> 1) follow the Spring mvc tutorial (which makes it happen for jsps) and
> then modify it for velocity (basically just by changing your view
> resolver as per the ch 13 (views) of the spring ref.)
> http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html
>
> 2) read the MVC chapter of the the spring docs
> (http://www.springframework.org/docs/reference/mvc.html) which will tell
> you all about controllers, handlers and viewresolvers.
>
> But the shortcut (I'm a spring novice ("spring chicken?" --groan), so
> might be a bit hack-y):
>
> Make a class to implement Controller
> (org.springframework.web.servlet.mvc.Controller)
> and then make sure you return a ModelAndView from the required
>
> public ModelAndView handleRequest(HttpServletRequest request,
> HttpServletResponse response) throws ServletException,
> IOException,
>
> the useful constructor (I think) here is
>
> ModelAndView(String viewName, Map model)
>
> so if you make a
> Map model = java.util.Hashtable();
> and then
> model.put("useful", myUsefulObject);
>
> then if you return your ModelAndView("mytemplate", model)
>
> then you refer to $useful in your "mytemplate.vm" file.
>
> But I would recommend following through the spring mvc tutorial (except
> for the last page on db-stuff which has lots of locking problems... at
> least when launched from within eclipse ...).
>
> Tim
>
> (Anyone who wants to improve any of my spring stupidity, please do!)
>
>
> > ----- Original Message ----- From: "Jack Holt" <ja...@gmail.com>
> > To: <ve...@jakarta.apache.org>
> > Sent: Friday, May 13, 2005 7:58 AM
> > Subject: Passing data into a Velocity Template from a Spring Controller
> >
> >
> > Can anyone tell me or point me to something that explains how to pass
> > data from a Spring controller to a Velocity Template? I know about
> > using Velocity View Resolvers. I have successfully called Velocity
> > Views from Spring Controllers but I'm unable to make the connection
> > between a Spring model and a Velocity context.
> > I've read all the documentation I can find on using Velocity with
> > Spring (for instance the section starting on page 139 of the Spring
> > Reference Manual).
> >
> > How do I make the connection?
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Passing data into a Velocity Template from a Spring Controller
Posted by Tim Diggins <su...@red56.co.uk>.
Hi Jack -
I found the following two bits of reference useful in getting started
with spring :
1) follow the Spring mvc tutorial (which makes it happen for jsps) and
then modify it for velocity (basically just by changing your view
resolver as per the ch 13 (views) of the spring ref.)
http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html
2) read the MVC chapter of the the spring docs
(http://www.springframework.org/docs/reference/mvc.html) which will tell
you all about controllers, handlers and viewresolvers.
But the shortcut (I'm a spring novice ("spring chicken?" --groan), so
might be a bit hack-y):
Make a class to implement Controller
(org.springframework.web.servlet.mvc.Controller)
and then make sure you return a ModelAndView from the required
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException,
the useful constructor (I think) here is
ModelAndView(String viewName, Map model)
so if you make a
Map model = java.util.Hashtable();
and then
model.put("useful", myUsefulObject);
then if you return your ModelAndView("mytemplate", model)
then you refer to $useful in your "mytemplate.vm" file.
But I would recommend following through the spring mvc tutorial (except
for the last page on db-stuff which has lots of locking problems... at
least when launched from within eclipse ...).
Tim
(Anyone who wants to improve any of my spring stupidity, please do!)
> ----- Original Message ----- From: "Jack Holt" <ja...@gmail.com>
> To: <ve...@jakarta.apache.org>
> Sent: Friday, May 13, 2005 7:58 AM
> Subject: Passing data into a Velocity Template from a Spring Controller
>
>
> Can anyone tell me or point me to something that explains how to pass
> data from a Spring controller to a Velocity Template? I know about
> using Velocity View Resolvers. I have successfully called Velocity
> Views from Spring Controllers but I'm unable to make the connection
> between a Spring model and a Velocity context.
> I've read all the documentation I can find on using Velocity with
> Spring (for instance the section starting on page 139 of the Spring
> Reference Manual).
>
> How do I make the connection?
>
> ---------------------------------------------------------------------
> 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
Re: Passing data into a Velocity Template from a Spring Controller
Posted by Will Glass-Husain <wg...@forio.com>.
The controller model should automatically populate the Velocity context. I
followed the examples in the Spring reference manual and it worked fine.
Let me make a simple example.
WILL
----- Original Message -----
From: "Jack Holt" <ja...@gmail.com>
To: <ve...@jakarta.apache.org>
Sent: Friday, May 13, 2005 7:58 AM
Subject: Passing data into a Velocity Template from a Spring Controller
Can anyone tell me or point me to something that explains how to pass
data from a Spring controller to a Velocity Template? I know about
using Velocity View Resolvers. I have successfully called Velocity
Views from Spring Controllers but I'm unable to make the connection
between a Spring model and a Velocity context.
I've read all the documentation I can find on using Velocity with
Spring (for instance the section starting on page 139 of the Spring
Reference Manual).
How do I make the connection?
---------------------------------------------------------------------
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