|
From: <jue...@we...> - 2003-07-02 14:03:52
|
Hi JP,
I can see what you were aiming at. But unfortunately you've =
misunderstood the purpose of the CookieThemeResolver's request =
attribute: It is only there to override the cookie value if changed in =
the course of the current request, to avoid reading the stale value from =
the cookie in the request object. It was never meant to be used by =
application developers, not in controllers and not in views. The =
attribute name contained the full CookieThemeResolver class name on =
purpose, as it is just an implementation detail.
The proper way to retrieve the name of the current theme is =
RequestContext.getTheme(), as used by ThemeTag underneath the hood. You =
can instantiate a RequestContext yourself, or instruct the View =
implementation to add an instance under a specified model attribute =
name, like as follows:
example.class=3Dcom.interface21.web.servlet.view.InternalResourceView
example.requestContextAttribute=3Drc
example.url=3D/example.jsp
With this configuration, a model attribute "rc" of type RequestContext =
is available for the view. With JSTL, you can simply access the current =
theme name via "${rc.theme.name}" then (specifying no scope simply =
searches page -> request -> session -> application).
I guess I haven't made RequestContext obvious enough. I'll revert the =
changes promptly, and add a respective comment to CookieThemeResolver.
Regards,
Juergen
-----Original Message-----
From: JP Pawlak [mailto:jp....@ti...]
Sent: Tuesday, July 01, 2003 10:15 PM
To: spr...@li...
Subject: [Springframework-developer] Theme issue
Hi Juergen, everybody,
I tried to test the current theme and locale in a view for avoiding
links to current choices. I encountered these issues and committed
changes.
1) The request attribute containing dots forces to use the brackets
syntax, but we can leave with this.
2) The request attribute is a bit long: <c:when
test=3D"${requestScope['com.interface21.web.servlet.theme.CookieThemeReso=
l
ver.THEME'] =3D=3D 'xxx'}">
3) The request attribute contains the implementation class name of the
resolver. If we change it in the configuration, the JSP have to be
changed accordingly :-(. For the point 2 and 3, I have changed the
request attribute name to the fixed String 'com.interface21.web.THEME'
defined now in ThemeResolver. I am aware that it breaks the backward
compatibility, but it solves this issue from this point (I think
especially on point 3).
4) When the theme is set, all is ok. But for next views, the current
theme name is no longer available, so the default is returned. I added a
new method 'makeThemeNameAvailable' in the ThemeResolver called by a new
else clause in ThemeChangeInterceptor. So, when an interceptor is used,
the request attribute is always set.
Regards,
Jean-Pierre
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|