Hi!

I'm developping a portlet and I want to use the PortletSession to pass
attributes between the Portlet and a JSP. This works perfectly when I
deploy the portlet locally (Pluto), but it doesn't when I access the
portlet through WSRP using WSRP4J (with Pluto) as producer.

Here's what I'm doing exactly:
1. invoke an actionURL in the JSP
2. processAction in the portlet will be called
3. set PortletSession attribute (the attribute is an object of MyClass)

   actionRequest.getPortletSession().setAttribute("myClass", new MyClass());

4. get MyClass object in JSP

   <%
        MyClass c = (MyClass)
renderRequest.getPortletSession().getAttribute("myClass");
   %>

5. display c.toString

  <% if (c != null) { %>  <%=c.toString()%> <%  } %>


It does work if the portlet is local but not when I consume it
remotely. That's why I assume it must have something to do with the
WSRP4J producer implementation. I don't get any error messages neither
on the consumer nor on the producer.

It is strange tough that if I use a String or an Integer object
instead of MyClass it even works with WSRP4J!

Any help would be appreciated,
Kevin

Here the code of the portlet:

public class SessionTestPortlet extends GenericPortlet {

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

                PortletContext context = getPortletContext();
                PortletRequestDispatcher disp = 
context.getRequestDispatcher("/jsp/"
                                + "view.jsp");
                disp.include(request, response);

        }

        public void processAction(ActionRequest actionRequest,
                        ActionResponse actionResponse) throws PortletException,
                        java.io.IOException {

                actionRequest.getPortletSession()
                                .setAttribute("myClass", new MyClass());
        }
}

Here the code of  view.jsp:

<%@ page session="true"%>
<%@ taglib uri="http://java.sun.com/portlet"; prefix="portlet"%>
<%@ page import="javax.portlet.*"%>
<%@ page import="java.util.*"%>
<%@ page import="session.test.portlet.MyClass"%>

<portlet:defineObjects />

<%
MyClass c = (MyClass) renderRequest.getPortletSession().getAttribute("myClass");
%>

<%
if (c == null) {
%>
<form action="<%=renderResponse.createActionURL()%>" method="post">
<input type="submit" value="Show MyClass" /></form>
<% } else { %>
   <%=c.toString()%>
<% } %>

Reply via email to