OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | exo-portlet-container List | April 2007 Index

<--  Date Index  --> <--  Thread Index  -->

Réf. : Re: Struts Portlet - InterPortlet Communication


Ok Alexey,
      I'm trying to explain:

My solution for the communication between two Struts portlets is not very
different.  I create two portlets which extends the StrutsPortlet
. I used the processAction of the portlet which emits to send a message and
the method doView of the portlet which receives
retrieves the message. Then there is two solution and i don't know if one
is better than the other.
In the doView method :


public void doView(RenderRequest request, RenderResponse response)
                throws PortletException, IOException {


              /* with the portlet-messaging library I find the message */
              PortletSession portletSession = request.getPortletSession(
true);
        String id = request.getRequestedSessionId();
        String msg_session_id = MessageHelper.getSessionID(request);

        // load this portlet's inputs and outputs from preferences
        MessageHelper.loadPrefs(request, id, msg_session_id);

        MessageHelper helper = new MessageHelper(portletSession, id,
                                                 msg_session_id);
        String messageReceived = helper.getAsString("mymessage");


            /* I get the ServletContextProvider */
            ServletContextProvider provider = this
.getServletContextProvider();

           /* first possibility */
      HttpServletRequest req =
      provider.getHttpServletRequest(this,request);

      req.setAttribute("messageReceived ", messageReceived );

       /* second possibility */
      ServletContext scontext = provider.getServletContext(this);
      scontext.setAttribute("messageReceived ", messageReceived );

            /* I call the doView method of the StrutsPortlet */
        super.doView(request, response);
    }



      To show the message
In the Jsp page

<!-- first possibility -->
<%= request.getAttribute("messageReceived ") %>

<!-- or -->

<!-- second one -->
<%= (String)(this.getServletContext().getAttribute("messageReceived ")) %>




Mickael Lecoq





<--  Date Index  --> <--  Thread Index  -->

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.