Win a copy of liveProject: Build an ML Recommender System this week in the Artificial Intelligence and Machine Learning forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

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
reply
    Bookmark Topic Watch Topic
  • New Topic