Using Spring Themes in Struts (or other non-Spring) Application Flows
June 30th, 2009 Prem Nagrath, Consultant (email the author)
Think it’s a weird kind of question? Not for people who have worked (or are working) on applications that are moving from one framework to another. I happened to work on one such project where a transition from Struts to Spring MVC was being done over a few releases. Not unexpectedly, this approach of supporting two frameworks at the same time gave the development team its own share of interesting challenges. And one such issue was how to use a new technology i.e. Spring themes in both frameworks, of course we could choose not to use it in enhancements to legacy Struts based application flows but then that would have meant doing the enhancements twice.
As a solution to this problem, all you need to do is make sure that the Spring beans for ThemeResolver and ThemeSource that you have defined in your config file, are available as request attributes. In a regular Spring MVC application flow, this would be done by the Dispatcher servlet but since in non-Spring MVC flow the control does not go through it, any attempt to use Spring themes would throw an error.
You can add the above mentioned Spring beans to the request in a number of ways and one of them is adding code to do this in a filter. So after including these two lines in your servlet filter, you should be able to use Spring themes in your Action Servlets as well as your JSPs:
request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE,yourThemeResolverBean)
request.setAttribute(DispatcherServlet.THEME_SOURCE_ATTRIBUTE,yourThemeSourceBean)
Entry Filed under: Agile and Development
Pages
Categories
- Agile and Development
- Application Modernization
- Cloud Applications
- Process Integration
- Summa
- Technology + Healthcare
- Uncategorized
Most Recent Posts
- Summa Is Award Finalist at IBM’s Impact 2012
- Working with JqGrid and ASP.NET MVC - Setting up a base jqgrid parameters class
- Rebase a Slave Mercurial Repo to a Subversion Master
- The Social Enterprise Part 2 – How To Set Up Chatter In Less Than 30 Minutes
- Implement Clear Governance for BRMS
Feeds
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « May | Jul » | |||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | |||||

Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed