I have a spring web app that uses Hibernate and Velocity. It’s an MVC app. I pass my ModelMaps down to the service level. And I also use my Hibernate persistence objects in the service level. I have these “domain” objects, which are basically the same thing as the persistence objects, except I include them in the ModelMap and make use of then in velocity. My questions is: can I do away with the “domain” object and use the persistence objects in the ModelMap, or that cause some kind of problems (maybe performance problems)?
Thanks for the help,
Joe
As long as you are writing the templates, and not some designer (and assuming that won’t change later), it is probably fine.
Your biggest gotcha will be catching errors. If something doesn’t load, you may already have sent a portion of the rendered template in the response. So, you will probably want to buffer the output, the VelocityLayoutServlet essentially does this by default (not for the layout template, but for the main content). The VelocityViewServlet will require you to flip a setting. I don’t recall which one, offhand. Look at the VelocityView class for more on that.