Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Tanaji Londhe
is it possible to invoke a function for every portlet request(ajax)
August 2, 2013 12:58 AM
Answer

Tanaji Londhe

Rank: Regular Member

Posts: 196

Join Date: April 25, 2012

Recent Posts

Is it possible to invoke function in theme, when i make any ajax(resorceRequest) request for any portlet ?
Sampsa Sohlman
RE: is it possible to invoke a function for every portlet request(ajax)
August 2, 2013 1:53 AM
Answer

Sampsa Sohlman

LIFERAY STAFF

Rank: Regular Member

Posts: 225

Join Date: September 27, 2007

Recent Posts

Hi Tanaij,

Tanaji M. Londhe:
Is it possible to invoke function in theme, when i make any ajax(resorceRequest) request for any portlet ?


Question what you are actually trying to do?

Still, let me try to answer. You can create Remote service with Servicebuilder and call these services through ajax. Your theme can use also these your own services and behave accordingly.
Tanaji Londhe
RE: is it possible to invoke a function for every portlet request(ajax)
August 2, 2013 2:29 AM
Answer

Tanaji Londhe

Rank: Regular Member

Posts: 196

Join Date: April 25, 2012

Recent Posts

Hi Sampsa,

In my portal I have disable simultaneous logins.
If userA logged on firefox browser and perform operation on custom portlet (custom portlet contains some ajax operation).
At the same time
If userA logged on chrome browser and perform operation on custom portlet. Now here firefox userA's session is timeout.
But till now firefox page is not refresh, when I perform some ajax operation on that (session is timeout for this browser), I get response as whole portal page with login portlet.
If page is refresh then it works properly, beacuse the page get redirect on login page.

Here I am trying to get event fire by any portlet (like ajax call only) on theme (I will check if this session is active or not) and then I redirect my portal page to login page if session expire.
David H Nebinger
RE: is it possible to invoke a function for every portlet request(ajax)
August 2, 2013 5:12 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11046

Join Date: September 1, 2006

Recent Posts

Or you could just go into portal-ext.properties and set auth.simultaneous.logins=false and then you wouldn't have to hack the system up...

Note that it's usually better to ask how to do what you need to do, rather than come up with some 'ingenious' plan and ask how to implement that...
Tanaji Londhe
RE: is it possible to invoke a function for every portlet request(ajax)
August 2, 2013 5:39 AM
Answer

Tanaji Londhe

Rank: Regular Member

Posts: 196

Join Date: April 25, 2012

Recent Posts

Or you could just go into portal-ext.properties and set auth.simultaneous.logins=false and then you wouldn't have to hack the system up...

I have already implement this functionality. There is no issue with that.

But try to think about this scenario,
- If userA logins in browser1 and perform some opration on my custom portlet (which contains some ajax request) and I leave this page as it is and open another browser2.
- If I open another browser2 logins userA.
Now browser2 session is active and browser1 session is expire(here i m not refreshing page).

Without resfreshing page in browser1, when i am trying hint any ajax request in this case, I got response as whole portal page with login portlet.
David H Nebinger
RE: is it possible to invoke a function for every portlet request(ajax)
August 2, 2013 8:22 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11046

Join Date: September 1, 2006

Recent Posts

Browser tabs are not separate login sessions. The browser shows you two tabs, but on the server it is still the same login session.

This is a 'feature' of IE, and there's not a darn thing you can do about it.

For example, log in then click on one of the links on the page and choose "open in new tab". You'll have two tabs both connected to your liferay single liferay session. One one of the tabs, click the sign out link. On the other tab, try clicking on something that requires you to be logged in (another tab in the navigation bar, for example). You will get tossed to the sign in because your true session on the server was closed.

The "auth.simultaneous.logins=false" in your portal-ext.properties file will only help when using two different browsers (one ie and one chrome for example). When UserA logs in the second browser, the first browser should kick back to the login page for any type of access for restricted resources (pages, portlets, etc.).
Sampsa Sohlman
RE: is it possible to invoke a function for every portlet request(ajax)
August 5, 2013 1:07 AM
Answer

Sampsa Sohlman

LIFERAY STAFF

Rank: Regular Member

Posts: 225

Join Date: September 27, 2007

Recent Posts

Tanaji M. Londhe:
Without resfreshing page in browser1, when i am trying hint any ajax request in this case, I got response as whole portal page with login portlet.


Now I have to admit, that I should debug the issue, to tell you more exact, but I won't emoticon .. it is what you should do.

Take a look what is the http status of the message and try to find out if the server is sending redirect, try to catch that on your js code. Then you should be able to create logic accordingly.
Tanaji Londhe
RE: is it possible to invoke a function for every portlet request(ajax)
August 5, 2013 2:57 AM
Answer

Tanaji Londhe

Rank: Regular Member

Posts: 196

Join Date: April 25, 2012

Recent Posts

Thanks Sampsa & David for reply.

I resolve like this
Before process any operation first I hit ajax call to check session is active or not.
If session is active I send one true flag and then I proceed.
If session is inactive then I got response as page data. Then I refresh my currrent page using javascript and it automatically redirect to login screen.... emoticon
David Ilechukwu
RE: is it possible to invoke a function for every portlet request(ajax)
August 5, 2013 4:26 AM
Answer

David Ilechukwu

Rank: Regular Member

Posts: 128

Join Date: June 7, 2010

Recent Posts

Nebinger's solutions above sound cleaner and more prone to writing a well-engineered software product. Why develop a hack when there are standard ways of achieving same result.
Tanaji Londhe
RE: is it possible to invoke a function for every portlet request(ajax)
August 5, 2013 11:19 PM
Answer

Tanaji Londhe

Rank: Regular Member

Posts: 196

Join Date: April 25, 2012

Recent Posts

Hi David Ilechukwu,

I have used that properties file to avoid same login with different browser.
But to handle ajax scenario (session timeout and page is not refresh) for that I used ajax call to check session is active or not.