-
1. How to send event to another page?
rraposa Jan 21, 2011 7:05 PM (in response to krokodylowy)What should you do with events? Use them between portlets on the same page! That is how they are meant to work.
What is your use-case? I suspect you can accomplish whatever you're trying to do using a different technique. If your event payload is a String, then a public render parameter might work fine on the page you are redirecting to. Otherwise, you can store the event payload in the APPLICATION_SCOPE of the portlet session and share it amongst portlets on the new page that way.
-
2. Re: How to send event to another page?
krokodylowy Jan 26, 2011 2:23 PM (in response to rraposa)Thanks for response.
Our portlet use standard events. Sometimes one portlet must send event to another page.
Another portals got some extension's which can be used for this case
- Liferay and Sun portlet-ext.properties:
portlet.container.impl=sun in portal-ext.properties.
portlet.event.distribution=ALL_PORTLETS
portlet.public.render.parameter.distribution=ALL_PORTLETS
portlet.event.max.generation=3
- Pluto got org/apache/pluto/driver/services/container/EventProviderImpl.java
Workaround should simulate IBM Websphere "cross-page-wire" like a "The IBM documentation says about exporting cross-page-wire: cross-page-wire: represents a property broker wiring between two portlet instances on either the same page or on different pages. A wire connects a source and a target portlet instance so that values which change in the source are propagated to the target"
Pluto got a simply solution. It expose PortalCallbackService.getEventProvider and I can simply add an event
to queue for next page.
I don't see any similar code in GateIn portal and portlet container (gatein/components/pc) sources.
-
3. How to send event to another page?
rraposa Jan 22, 2011 12:06 PM (in response to krokodylowy)Hi Krashan,
I see that now - I didn't realize other portals provided an implementation extension for event communication between pages. That capability is not a part of the JSR286 spec.
I do not believe GateIn has this capability.
Rich
-
4. How to send event to another page?
krokodylowy Jan 23, 2011 12:13 PM (in response to rraposa)The best approach should be a some kind of injection after 'cpn.execute' directly to ProcessEventsActionListener but some test do not get a working solution (but portal page is changed)
UIPortal uiPortal = Util.getUIPortal();
PageNodeEvent<UIPortal> pnevent;
pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, prContext.getPortalURI()
+ destinationPage);
UIPageActionListener.ChangePageNodeActionListener cpn = new UIPageActionListener.ChangePageNodeActionListener();
cpn.execute(pnevent);
...
-
5. Re: How to send event to another page?
krokodylowy Jan 27, 2011 2:17 PM (in response to krokodylowy)Partial solution
- works good with jsp portlets
- page is changed and rendered but requestContext keep's old url (so if needed it can changed only with adding context.redirect(..newPage)
at the end
- sometimes not work's correctly wih jsf portlet's, page switch break jsf lifecycle so portlet on old page throws NPE (new jsp portlet on
new page is displayed correctly)
-----------------------------------------
PortalRequestContext portalContext = (PortalRequestContext) WebuiRequestContext.getCurrentInstance();
// change page
UIPortal uiPortal = Util.getUIPortal();
PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, destinationPage);
UIPageActionListener.ChangePageNodeActionListener cpn = new UIPageActionListener.ChangePageNodeActionListener();
cpn.execute(pnevent);
// push event to new page and portlet
WebuiRequestContext context = Util.getPortalRequestContext();
UIPortalApplication currentPortal = Util.getUIPortalApplication();
UIPortal currentSite = currentPortal.getShowedUIPortal();
PageNode foundPage = ExoPortalUtils.findPageInNavigations(currentPortal.getNavigations(), destinationPage);
if (foundPage == null) {
// page not found force standard redirect
portalContext.setResponseComplete(true);
portalContext.getResponse().sendRedirect(portalContext.getPortalURI()+ destinationPage);
return;
}
// locate ui page
UIPage foundUIPage = Util.toUIPage(foundPage, currentSite);
// locate ui portlet if defined by name
UIPortlet foundUIPortlet = null;
if (portlet != null && portlet.length() > 0)
foundUIPortlet = ExoPortalUtils.findPortletByName(foundUIPage,portlet);
// read current events
EventsWrapper eventsWrapper = (EventsWrapper)portalContext.getAttribute(UIPortletActionListener.PORTLET_EVENTS);
List<javax.portlet.Event> events = eventsWrapper != null ?eventsWrapper.getEvents() : null;
if (events == null)
events = new ArrayList<javax.portlet.Event>();
// register event for page or portlet
javax.portlet.Event portletEvent = new PortletEvent( new QName(XMLConstants.NULL_NS_URI, event.getActionName()), event);
events.add(portletEvent);
portalContext.setAttribute(UIPortletActionListener.PORTLET_EVENTS,new EventsWrapper(events));
// send event to page or portlet, correct flow may be seen and logged in classes UIPortletActionListener,
// PortletApplication, StateAwareResponseImpl i ProcessEventsActionListener u
if (foundUIPortlet != null) {
foundUIPortlet.createEvent("ProcessEvents",org.exoplatform.webui.event.Event.Phase.PROCESS, portalContext)
.broadcast();
} else {
foundUIPage.createEvent("ProcessEvents",org.exoplatform.webui.event.Event.Phase.PROCESS, portalContext)
.broadcast();
}
// send redirect if requestContext must keep page track
// portalContext.getResponse().sendRedirect(portalContext.getPortalURI()+ destinationPage);
-----------------------------------------