01: package org.wings.resource;
02:
03: import org.wings.*;
04: import org.wings.session.SessionManager;
05:
06: /**
07: * Quite similar to the DefaultURLResource. Though this resource supports url rewriting for cookie-less sessions.
08: * Thus it can address resources below the servlet path.
09: */
10: public class SessionResource implements URLResource {
11: private final SimpleURL url;
12:
13: /**
14: * @param url The URL to access this ressource.
15: */
16: public SessionResource(String url) {
17: this .url = new SimpleURL(url);
18: }
19:
20: public SimpleURL getURL() {
21: RequestURL requestURL = (RequestURL) SessionManager
22: .getSession().getProperty("request.url");
23: if (requestURL != null) {
24: requestURL = (RequestURL) requestURL.clone();
25: requestURL.setResource(url.toString());
26: return requestURL;
27: } else
28: return url;
29: }
30: }
|