• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Spring and Multiple View Resolvers

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am having trouble with the following problem: there is a need to put two web apps (that are implemented using spring portlet mvc) into a single app. Each of the apps has a similar directory structure, and some of the files (jsp's and portlet descriptors) have the same names, thus making it impossible to put apps' contents into the same folders.

But now, if I put jsp's into separate folders, then (if my understanding is correct) I need either a separate view resolver for each of them, or prepend all references to view names with the folder names where those jsp's are moved to. The latter solution means there must be thousands of changes within java code and descriptors (the applications include quite a number of portlets), and lots of testing, which is really not acceptable.

I looked at the spring documentation and it says that it's possible to define several view resolver beans in the application context, and then when determining the full view name each of them is checked until one returns a view (order of checking can be different, etc.).

What I don't know is whether it is possible to use the same view resolver (i. e. the same implementation). I tried to do like this:



for one folder of jsp's, and



for another one.

The result is that views for the first folder, /WEB-INF/jsp/wap/, are being resolved, but for the second one I get blank pages (without any errors in the app server logs). Spring documentation says, that some resolvers, like InternalResourceViewResolver, return a non-null view in any case, so, it is very probable that the actual views are not being resolved with no errors.

Maybe someone knows if I'm using the right approach and if it is correct to use the same view resolver implementation (InternalResourceViewResolver in my case)? Or is there another, a better solution to the problem? Or maybe multiple view resolver definitions need some additional properties to be set?
 
Arjana Matonyte
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to solve the problem by configuring a separate InternalResourceViewResolver for each portlet within each of their application context files and giving them a high priority order. This approach works but it required changes within a lot of xml files and people extending applications need to be aware of the need to provide a view resolver bean for their new portlets. Maybe someone knows a better approach?
 
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another approach is to use a single InternalResourceViewResolver, i.e.


you can then simply include the name of the folder as part of the view name
 
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic