|
From: <jue...@we...> - 2004-05-16 15:49:52
|
I'm not too fond of this idea in general, as it contains the view type =
as prefix in the symbolic view name - while the view name ideally =
shouldn't know anything about the view implementation type. Of course, =
if it works for you, then it's an appropriate solution for you :-)
=20
As a general solution, I prefer the ability to specify multiple =
ViewResolver beans in a DispatcherServlet context - a change that we =
have already agreed on for Spring 1.0.2. Those ViewResolver beans can be =
ordered through "order" values, returning null if they can't resolve a =
view name, letting the next ViewResolver in the chain have a try.
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Timo Verhoeven
Gesendet: Do 06.05.2004 14:36
An: spr...@li...
Betreff: Re: [Springframework-developer] RE: [Springframework-user] =
chain ViewResolvers?
Hello,
this might be slightly off-topic.
I used to work with the InternalResourceViewResolver for convenience
until I needed support for additional View classes (redirects in my
case). However, I did not want to map every view explicitly, as in the
countries and petclinic samples, and came up with another idea: I wrote
a simple DelegatingViewResolver which maps prefixes to ViewResolvers.
The configuration looks like this:
<bean id=3D"defaultViewResolver"
=
class=3D"org.springframework.web.servlet.view.InternalResourceViewResolve=
r">
<property
name=3D"viewClass"><value>org.springframework.web.servlet.view.JstlView</=
value></property>
<property name=3D"prefix"><value>/WEB-INF/intranet/</value></property>
<property name=3D"suffix"><value>.jspx</value></property>
</bean>
<bean id=3D"redirectViewResolver"
class=3D"de.tcv.da.customerservice.util.RedirectViewResolver"/>
=20
<bean id=3D"viewResolver"
class=3D"de.tcv.da.customerservice.util.DelegatingViewResolver">
<property name=3D"defaultResolver">
<ref local=3D"defaultViewResolver"/>
</property>
<property name=3D"prefixMappings">
<map>
<entry key=3D"redirect"><ref =
local=3D"redirectViewResolver"/></entry>
</map>
</property>
</bean>
Now I can have view names like "redirect:http://www.google.com",
"redirect:index.page", and "showCustomer.page" without sacrificing the
convenience of the InternalResourceViewResolver for my jspx files.
This could be easily extended to multiple InternalResourceViewResolver
instances to support more View classes, yielding view names like
"xls:customer", "pdf:customer", "jsp:index", etc. The separator is
configurable.
If it's any useful to others I can contribute my DelegatingViewResolver
and RedirectViewResolver sources.
Regards,
Timo
-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=3Dosdnemail3
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|