ton*_*ton 5 javascript ajax session-state liferay-6
我创建了一个使用AJAX每个函数的portlet.也就是说,portlet只渲染一次而我没有使用processAction等.
有没有办法使用内置的Liferay函数使用javascript扩展用户的会话?
我试过了
Liferay.Session.extend();
Run Code Online (Sandbox Code Playgroud)
但它似乎没有工作..
我也在ICEfaces论坛上试过一个解决方案
if (Liferay.Session._stateCheck) {
window.clearTimeout(Liferay.Session._stateCheck);
Liferay.Session._stateCheck = null;
}
Liferay.Session.init({
autoExtend: false,
timeout: Liferay.Session._timeout,
timeoutWarning: Liferay.Session._warning
});jQuery.ajax({url: Liferay.Session._sessionUrls.extend});
Run Code Online (Sandbox Code Playgroud)
也没工作..
每当用户点击按钮时,我都会放置这些代码块
任何提示都会有很大帮助..
我有同样的问题并解决了。主要思想是将session.js覆盖到ext-plugin中,并添加一些额外的方法:
extendExternal: function() {
var instance = this;
if (instance != undefined) {
instance.extend();
}
}
Run Code Online (Sandbox Code Playgroud)
setCookie 方法也应该更新:
setCookie: function(status) {
var instance = this;
var currentTime = new Date().getTime();
var options = {
secure: A.UA.secure,
path: "/"
};
A.Cookie.set(instance._cookieKey, status || currentTime, options);
}
Run Code Online (Sandbox Code Playgroud)
为了每个页面使用相同的cookie路径。
一些全局ajax事件可用于“自动”调用extendExternal方法:
AUI().use('event', function(A){
A.on('io:start', function(transactionid, arguments){
if (Liferay.Session._cookieKey != undefined && Liferay.Session._cookieKey != null) {
if (arguments != 'sessionExtend') {
Liferay.Session.extendExternal();
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
在这种情况下,扩展方法必须更新为:
// added in order to differentiate session extend ajax calls and other ajax call, to avoid infinit loop
A.io.request(instance._sessionUrls.extend, {
arguments: 'sessionExtend'
});
Run Code Online (Sandbox Code Playgroud)
您可以在此处检查解决方案。