执行AJAX调用时延长的Liferay会议 [英] extend session of Liferay when performing AJAX call
问题描述
我创建了一个使用AJAX的每一个功能的portlet。 也就是说,该portlet仅呈现一次,我没有利用的processAction等。
有没有一种方法来扩展用户的会话使用使用javascript内置Liferay的功能?
我试过
Liferay.Session.extend();
但它似乎并没有工作..
我也试过在ICEfaces的论坛解决方案,这是
如果(Liferay.Session._stateCheck){
window.clearTimeout(Liferay.Session._stateCheck);
Liferay.Session._stateCheck = NULL;
}
Liferay.Session.init({
AUTOEXTEND:假的,
超时:Liferay.Session._timeout,
timeoutWarning:Liferay.Session._warning
}); jQuery.ajax({网址:Liferay.Session._sessionUrls.extend});
也不能正常工作。
我把code区块每当用户点击一个按钮
任何提示将极大地帮助。
解决方案我有同样的问题,解决了它
extendExternal:函数(){
VAR实例=这一点;
如果(比如!=未定义){
instance.extend();
}
}
也setCookie方法方法应该被更新:
setCookie方法:功能(状态){
VAR实例=这一点;
VAR currentTime的=新的日期()的getTime()。
VAR的选择= {
安全:A.UA.secure,
路径: /
};
A.Cookie.set(instance._cookieKey,状态|| currentTime的,选项);
}
为了使用相同的cookie路径为每个网页
和一些全局AJAX事件可用于extendExternal法自然而然的呼叫:
AUI()。使用('事件',功能(A){
A.on('IO:启动,功能(TRANSACTIONID,参数){
如果(Liferay.Session._cookieKey =不确定和放大器;!&安培;!Liferay.Session._cookieKey = NULL){
如果(参数!='sessionExtend'){
Liferay.Session.extendExternal();
}
}
});
});
在这种情况下,扩展方法也能与更新:
//添加以区分会话扩展Ajax调用等Ajax调用,避免无穷远环
A.io.request(instance._sessionUrls.extend,{
参数:'sessionExtend
});
您可以检查解决方案这里。
I created a portlet that uses AJAX every function. That is, the portlet is only rendered once and i didnt utilize processAction or the like.
Is there a way to extend the user's session using built in Liferay function using javascript?
I tried
Liferay.Session.extend();
but it does not seem to work..
I also tried a solution in the ICEfaces forum, which is
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});
also not working..
I put those blocks of code whenever the user clicks a button
Any tip would greatly help..
I had same issue and solved it. The main idea is to override session.js into ext-plugin, and add some additional method:
extendExternal: function() {
var instance = this;
if (instance != undefined) {
instance.extend();
}
}
also setCookie method should be updated:
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);
}
In order to use the same cookie path for each page.
And some global ajax event can be used for 'automatical' call of extendExternal method:
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();
}
}
});
});
in this case extend method have to be updated with:
// 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'
});
You can check solution here.
这篇关于执行AJAX调用时延长的Liferay会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!