Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Patrick Warnecke
Destructor on page leave?
11 marzo 2013 4.07
Risposta

Patrick Warnecke

Punteggio: New Member

Messaggi: 20

Data di Iscrizione: 30 novembre 2012

Messaggi recenti

Hi,
I was wondering if it is possible to have a method called everytime I leave a page in my portal. Best case would be if I can configure it with annotations or something like that but if there ist only a method that is bound to the whole page or something that's at least a start.
While searching the web I found solutions for the case when a portlet is removed from a page (e.g. through a portlet-layout-listener) but that is not what I want.
I want something in the direction of a "page change" listener.
Any help, like always, is appreciated!
Mika Koivisto
RE: Destructor on page leave?
11 marzo 2013 15.16
Risposta

Mika Koivisto

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1513

Data di Iscrizione: 7 agosto 2006

Messaggi recenti

Only way I can think of implementing this is with javascript.
Patrick Warnecke
RE: Destructor on page leave?
14 marzo 2013 2.49
Risposta

Patrick Warnecke

Punteggio: New Member

Messaggi: 20

Data di Iscrizione: 30 novembre 2012

Messaggi recenti

Well ok if that is the only why I will try to do that.
Care to explain how I can fire a Java method from JavaScript? I'm only a trainee in my company and could only find examples while using JSPs, but my company wants to use JSF (PrimeFaces).
Thanks in advance!
David H Nebinger
RE: Destructor on page leave?
14 marzo 2013 5.59
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11295

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

This is going to be difficult if not impossible, depending upon your definition of "leave the page".

If it is just "navigate to a different portal page", that's going to be tough enough. You'd have to add javascript to find all links on the page (<a /> tags) and insert javascript to send an event about the navigation. You'd have to be aware of things like the dockbar, the navigation tabs, the breadcrumbs, ...

If your definition also includes "typing a new url in the browser address bar", "choosing a browser favorite", "clicking the back button", and/or "closing the browser tab/window", you're SOL.
Hitoshi Ozawa
RE: Destructor on page leave?
14 marzo 2013 6.30
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

Is there any reason for calling a destructor on a page leave? What would happen if an user just close the web browser.
You do understand the two phases of a portlet. You shouldn't need to be calling a destructor in a view mode.

http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/understanding-the-two-phases-of-portlet-executi-4
Patrick Warnecke
RE: Destructor on page leave?
14 marzo 2013 7.33
Risposta

Patrick Warnecke

Punteggio: New Member

Messaggi: 20

Data di Iscrizione: 30 novembre 2012

Messaggi recenti

@David H Nebinger:
Firing the java method when the user switches the page would at least be a start, ideally I want everything covered.

@Hitoshi Ozawa:
The reason I want this is the following. I have a central application, deployed through an ext-plugin, where every portlet registers itself when it is first instantiated. I do this to implement inter portlet communication, 'cause our whole portlet setup is quite complex (several war-files, no jsps, no javascript ipc). So from time to time the registered portlets get an event from the central application, but they don't need to get that event if the page the portlet is on isn't even open.

It's no necessity, but it would be nice to have.
David H Nebinger
RE: Destructor on page leave?
14 marzo 2013 8.16
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11295

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

Sounds like you've got a completely wrong implementation...

I'd approach this using the LMB. Central app can push messages out to a destination that your portlets can listen on. Your portlets can publish messages to a destination the central app is listening on.

Would seem to have nothing to do with what is going on in the user's browser...
Patrick Warnecke
RE: Destructor on page leave?
14 marzo 2013 8.40
Risposta

Patrick Warnecke

Punteggio: New Member

Messaggi: 20

Data di Iscrizione: 30 novembre 2012

Messaggi recenti

If it's possible we don't want to be liferay dependet for customers who prefer another portal...
But thanks for the reminder about LMB, maybe we will change to that, we'll see.
David H Nebinger
RE: Destructor on page leave?
14 marzo 2013 10.47
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11295

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

Now this makes even less sense. There will not be any portal-neutral way to accomplish the 'destructor on page leave' concept. The only portal-neutral paths you have are those specified by the JSRs, and they certainly don't cover this...

So to implement what you want, you will be doing portal-specific implementations, you don't really have another choice.
Hitoshi Ozawa
RE: Destructor on page leave?
14 marzo 2013 15.05
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

It's possible to check if a portlet is place on a page using liferay's API and I think the better way is to do it like what some of liferay's portlet are doing and just have each portlet check before doing inter-portlet communication.
Patrick Warnecke
RE: Destructor on page leave?
14 marzo 2013 23.54
Risposta

Patrick Warnecke

Punteggio: New Member

Messaggi: 20

Data di Iscrizione: 30 novembre 2012

Messaggi recenti

David H Nebinger:
Now this makes even less sense. There will not be any portal-neutral way to accomplish the 'destructor on page leave' concept. The only portal-neutral paths you have are those specified by the JSRs, and they certainly don't cover this...

So to implement what you want, you will be doing portal-specific implementations, you don't really have another choice.



It's not that I want to completely avoid Portalspecific functions, I'm well aware that I have to use a few of those. But I kind of want to avoid functionallity that is only present in liferay. We're planning on encapsulating the portalspecific funtions. If you get what I'm trying to say.

But like I said, I will reconsider using LMB and I'll look into what Hitoshi said. Thanks for all of you answers!