01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08:
09: package com.gwtext.client.state;
10:
11: import com.gwtext.client.core.BaseConfig;
12: import com.gwtext.client.util.JavaScriptObjectHelper;
13:
14: import java.util.Date;
15:
16: /**
17: * CookieProvider configuration.
18: */
19: public class CookieProviderConfig extends BaseConfig {
20:
21: /**
22: * The path for which the cookie is active (defaults to root '/' which makes it active for all pages in the site).
23: *
24: * @param path the path
25: */
26: public void setPath(String path) {
27: JavaScriptObjectHelper.setAttribute(jsObj, "path", path);
28: }
29:
30: /**
31: * The cookie expiration date (defaults to 7 days from now).
32: *
33: * @param days number of days
34: */
35: public void setExpires(int days) {
36: Date now = new Date();
37: long millis = now.getTime() + (1000 * 60 * 60 * 24 * days);
38: JavaScriptObjectHelper.setAttribute(jsObj, "expires", millis);
39: }
40:
41: /**
42: * The domain to save the cookie for. Note that you cannot specify a different domain than your page is on, but you
43: * can specify a sub-domain, or simply the domain itself like 'extjs.com' to include all sub-domains if you need to
44: * access cookies across different sub-domains (defaults to null which uses the same domain the page is running on including the 'www' like 'www.extjs.com')
45: *
46: * @param domain the domain
47: */
48: public void setDomain(String domain) {
49: JavaScriptObjectHelper.setAttribute(jsObj, "domain", domain);
50: }
51:
52: /**
53: * True if the site is using SSL (defaults to false).
54: *
55: * @param secure true if using SSL
56: */
57: public void setSecure(boolean secure) {
58: JavaScriptObjectHelper.setAttribute(jsObj, "secure", secure);
59: }
60: }
|