I am trying integrate a Struts Portlet using Struts Bridge and an InterPortlet Communication library, http://www.doc.ic.ac.uk/~mo197/portlets/portlet_messaging/crosscontext.php , which works well with ordinary portlets.
The library requires that I retrieve the PortletRequest / ActionRequest / RenderRequest. However within my Struts Portlet I only action and form classes and with execute I only have httpServletRequest available. Given that my action classes are running within s struts portlet how can I retrieve the PortletRequest that I need. The following code shows a simple portlet that works fine. public class Portlet1 extends GenericPortlet{ protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException { String id = this.getInstanceID(request); String msg_session_id = MessageHelper.getSessionID(request); MessageHelper.loadPrefs(request, id, msg_session_id); MessageUtils.prepareMappingForm(request, id, msg_session_id); getPortletContext().getRequestDispatcher("/WEB-INF/pages/edit_mappings.jsp").include(request,response); } protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { String id = this.getInstanceID(request); String msg_session_id = MessageHelper.getSessionID(request); MessageHelper.loadPrefs(request, id, msg_session_id); response.setContentType("text/html"); PrintWriter out = response.getWriter(); PortletURL aURL = response.createActionURL(); aURL.setParameter("ACTION", "sendmsg"); out.println("<b>Message Session ID:</b> "+msg_session_id+"<br/>"); out.println("<b>Portlet App:</b> "+request.getContextPath()+"<br/>"); out.println("<b>Portlet1</b>:<br/>"); out.println("<a href=\""+aURL+"\">send message</a><br/><br/>"); MessageHelper msgh = new MessageHelper(request.getPortletSession(true), id, msg_session_id); String msg = (String)msgh.get("a_val"); out.println("my a_val msg: "+msg); } public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { String id = this.getInstanceID(request); String msg_session_id = MessageHelper.getSessionID(request); MessageHelper.loadPrefs(request, id, msg_session_id); if (request.getPortletMode().equals(PortletMode.EDIT)) { MessageUtils.processMappingForm(request, response, id, msg_session_id); } if ("sendmsg".equals(request.getParameter("ACTION"))){ System.out.println("try sending message from Portlet 1 in webapp "+request.getContextPath()); MessageHelper msgh = new MessageHelper(request.getPortletSession(true), id, msg_session_id); msgh.send("a_val", "this is a message from Portlet1 in portlet webapp "+request.getContextPath()); } } public String getInstanceID(PortletRequest request){ return "Portlet1."+MessageHelper.getPortletID(request); } } Hopefully from that you can see what I am trying to retrieve from within my action class. The following is my current execute method logger = Logger.getLogger("Cedar-Portlets"); logger.debug("SetURLAction::execute - starting"); try { ActionRequest actionRequest = (ActionRequest) request .getAttribute(ContainerConstants.PORTLET_REQUEST); String id = this.getInstanceID(actionRequest); String msg_session_id = MessageHelper.getSessionID(actionRequest); MessageHelper.loadPrefs(actionRequest, id, msg_session_id); MessageHelper msgh = new MessageHelper(actionRequest .getPortletSession(true), id, msg_session_id); msgh.send("a_val", "this is a message from SetURLAction in portlet webapp " + actionRequest.getContextPath()); } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); return mapping.findForward("failure"); } return mapping.findForward("success"); Which doesn't work, any ideas would be greatly appreciated. Jon Hawkins --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]