|
I sent Nate an email and he gave me an update -- the listening feature in #2 above has been implemented in the Liferay trunk and will appear in Liferay 5.0. Here are his instructions:
To subscribe to the close portlet event you would type: Liferay.Publisher.subscribe( 'closePortlet', fn, [scope] ); The first parameter is the event that is subscribed, in this case closePortlet. The next parameter is a function that will be executed when the portlet is closed, and the third parameter is option, and it's an object that sets the scope that you wish to execute your Javascript in. So for instance, if you wanted to remap the this object in the function you're passing in, you would pass that object. But of course, it's optional. Here is an example of how you would use it: Liferay.Publisher.subscribe( 'closePortlet', function (plid, portletId) { console.log(plid, portletId); } ); We can do one of two things here:
1) Document it as something for the developer to add themselves. However, we'll have to also document what they should do (i.e. what ICEfaces API they should call) when a portlet is removed so that the ICEfaces bridge can do what it needs to do. 2) We can add this Liferay specific code to our bridge so that it's only executed in the appropriate environment. This is obviously more transparent for the developer but it also means adding platform specific code to the bridge. There are different ways to do that as well. We can include it always or do something more dynamic or offer some sort of configuration switch for the developer so they can turn it on if they need it since dynamically adding/removing portlets is not always available to all users. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Is this still an issue?
If it is, then I thought it best to record here a summary of the IM discussion I had with Derek on this issue back on 1/22/2008:
Derek explained the problem a little further:
"If you close one, the bridge has no way of knowing and throws JavaScript errors. It's trying to maintain the portlet that went missing. It's the reverse problem of adding it dynamically."
Derek presented the following two ideas as potential solutions:
1. Force the page to reload when the portlet is removed from the page
2. Hook into the Liferay JavaScript API and receive notifications for when a portlet is removed from a page
Liferay doesn't have a means to do #1. Regarding #2, I got on IM with Liferay's Nate Cavanaugh, and he said that there is currently no mechanism in the Liferay javascript API to register a listener to hear when a portlet is removed from the page. However, he wrote that he has wanted to do that for a long time, and it would be super easy to do.
If this is still an issue then I'll get back with Nate and see if we can't get #2 implemented.