How to share a bean?
To share a bean, you have to:
-
Create a jar that contains the class of the bean.
-
Put the jar in the shared lib of your application server.
-
Share the bean as any simple object.
/**
* SimpleEvent class is in a shared lib.
*
* Example of processAction(…) of any portlet
*/
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException {
Map map = (Map) actionRequest.getAttribute("jahiaSharedMap");
map.put("simpleEvent",
new SimpleEvent(new Date(), "simple event test"));
actionRequest.setAttribute("jahiaSharedMap", map);
}
/**
* SimpleEvent class is in a shared lib.
*
* Example of render(…) of any other portlet
*/
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
Map map = (Map) renderRequest.getAttribute("jahiaSharedMap");
SimpleEvent event = ((SimpleEvent)map.get("simpleEvent"));
}

