[Seaside] Displaying an expiration page: solution
vincent.girard-reydet at f4-group.com
Fri Jan 19 15:35:34 UTC 2007
I think I found an elegant solution to the problem I submitted a few
days ago (displaying an expiration page when the session timeouts,
instead of displaying directly the application's default page).
I'de appreciate if people can tell me wether or not they see a more
elegant way to do it, or restrictions.
Additionnaly, I'de like to automatically redirect the user to the
default page after a certain amount of time (say, 5 seconds). Does
someone know how to dot it proper ?
Here is the explanation. You need first to subclass #WAApplication
WAApplication subclass: #CBOApplication
#CBOApplication >> #expiryPathFor: aRequest
^ self basePath , '/expired'
#CBOApplication class >> #description
^ 'My customized application'
Now, in seaside/config you can create a new type of application.
Your root component must implement #initialRequest:.
For example, I have a root component that acts as a container for a
navigation bar, header and actual component:
#CBORootComponent >> #initialRequest: aRequest
| path |
self session tryAutoLogin.
"Other stuff like detecting user's favorite language"
"Read the end of the request path top deduce which component to display"
"Here assume we have only one level below the root path"
path := (aRequest url findTokens: '/') last asLowercase.
path = 'expired'
ifTrue: [actualComponent := CBOExpiredComponent]
ifFalse: [actualComponent := CBORootComponent].
Of course you can use a dictionary to map paths to components.
When the user is redirected to yourserver.org:8080/root/expired, the
CBOExpiredComponent will be displayed.
You can test it for example in Sushi application. Remove the path,
register it again using your custom app, change the expiration time to
10s => you'll see the expiration page after 10s.
More information about the Seaside