Foros de discusión

is it possible to invoke a function for every portlet request(ajax)

thumbnail
Tanaji M. Londhe, modificado hace 10 años.

is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 194 Fecha de incorporación: 25/04/12 Mensajes recientes
Is it possible to invoke function in theme, when i make any ajax(resorceRequest) request for any portlet ?
thumbnail
Sampsa Sohlman, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 230 Fecha de incorporación: 27/09/07 Mensajes recientes
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.
thumbnail
Tanaji M. Londhe, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 194 Fecha de incorporación: 25/04/12 Mensajes recientes
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.
thumbnail
David H Nebinger, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
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...
thumbnail
Tanaji M. Londhe, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 194 Fecha de incorporación: 25/04/12 Mensajes recientes
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.
thumbnail
David H Nebinger, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
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.).
thumbnail
Sampsa Sohlman, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 230 Fecha de incorporación: 27/09/07 Mensajes recientes
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.
thumbnail
Tanaji M. Londhe, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 194 Fecha de incorporación: 25/04/12 Mensajes recientes
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, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 154 Fecha de incorporación: 7/06/10 Mensajes recientes
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.
thumbnail
Tanaji M. Londhe, modificado hace 10 años.

RE: is it possible to invoke a function for every portlet request(ajax)

Regular Member Mensajes: 194 Fecha de incorporación: 25/04/12 Mensajes recientes
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.