本文整理汇总了Java中com.google.gwt.storage.client.Storage.getSessionStorageIfSupported方法的典型用法代码示例。如果您正苦于以下问题:Java Storage.getSessionStorageIfSupported方法的具体用法?Java Storage.getSessionStorageIfSupported怎么用?Java Storage.getSessionStorageIfSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.storage.client.Storage
的用法示例。
在下文中一共展示了Storage.getSessionStorageIfSupported方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static String get(String prefname) {
String value = null;
// check browser session storage
Storage sessionStorage = Storage.getSessionStorageIfSupported();
if (sessionStorage != null) {
value = sessionStorage.getItem(PREFIX+prefname);
}
// check browser local storage
if (value == null) {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
value = localStorage.getItem(PREFIX+prefname);
}
}
// check map
if (value==null) {
value = localPrefMap.get(prefname);
}
return value;
}
示例2: getSessionStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
/**
* Returns a Session Storage.
*
* @return the sessionStorage instance, or <code>null</code> if Web Storage is NOT supported.
*/
public static StorageExt getSessionStorage() {
if (sessionStorage == null && Storage.isSessionStorageSupported()) {
sessionStorage = new StorageExt(Storage.getSessionStorageIfSupported());
}
return sessionStorage;
}
示例3: set
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static void set(String prefname, String prefvalue, boolean sessionScope) {
if (sessionScope) {
// put preference into session storage, if available
// otherwise into local static map
Storage sessionStorage = Storage.getSessionStorageIfSupported();
if (sessionStorage != null) {
//oldvalue = sessionStorage.getItem(PREFIX+prefname);
if (prefvalue == null) {
sessionStorage.removeItem(PREFIX+prefname);
} else {
sessionStorage.setItem(PREFIX+prefname, prefvalue);
}
} else {
//oldvalue = localPrefMap.get(prefname);
localPrefMap.put(prefname, prefvalue);
}
}
else {
// check browser local storage
Storage localStorage = Storage.getLocalStorageIfSupported();
String oldvalue;
if (localStorage != null) {
oldvalue = localStorage.getItem(PREFIX+prefname);
if (prefvalue == null) {
localStorage.removeItem(PREFIX+prefname);
} else {
localStorage.setItem(PREFIX+prefname, prefvalue);
}
} else {
oldvalue = localPrefMap.get(prefname);
localPrefMap.put(prefname, prefvalue);
}
if (notBulkUpdate && loginManager != null && loginManager.isLoggedIn()) {
if ((prefvalue != null && !prefvalue.equals(oldvalue)) ||
(oldvalue != null && !oldvalue.equals(prefvalue))) {
// logged in user - also put preferences to db
loginManager.setPreference(prefname, prefvalue);
}
}
}
// no need to fire event
// fire event if preference value has changed
//if ((prefvalue != null && !prefvalue.equals(oldvalue)) ||
// (oldvalue != null && !oldvalue.equals(prefvalue))) {
// HashMap<String,String> prefmap = new HashMap<String,String>(1);
// prefmap.put(prefname,prefvalue);
// WebEventManager.getAppEvManager().fireEvent(new WebEvent(Preferences.class, Name.PREFERENCE_UPDATE, prefmap));
//}
}
示例4: StorageBackend
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
StorageBackend() {
storageBackend =
(Storage.isLocalStorageSupported())
? Storage.getLocalStorageIfSupported()
: Storage.getSessionStorageIfSupported();
}