admin管理员组文章数量:1393843
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 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..
Share Improve this question asked Mar 1, 2012 at 2:52 tonton 3553 silver badges13 bronze badges 2-
1
Liferay.Session.extend();
is the answer, i didnt notice that the session is extended when testing the code – ton Commented Mar 1, 2012 at 6:25 - Hi, please create answer and put your solution from ment to it, and accept it. That way people will immediately know that there is solution for this question. – Martin Gamulin Commented Mar 1, 2012 at 10:20
2 Answers
Reset to default 4I 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.
Liferay.Session.extend(); is the answer, i didnt notice that the session is extended when testing the code
本文标签: javascriptextend session of Liferay when performing AJAX callStack Overflow
版权声明:本文标题:javascript - extend session of Liferay when performing AJAX call - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744083248a2588042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论