You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Zoltan Grose <zg...@mac.com> on 2003/06/06 19:45:05 UTC

Empty Context in do* methods

I'm just getting started with Jetspeed so hopefully I haven't missed  
something obvious.

I am developing a Message-of-the-Day style portlet that stores its  
message as a parameter in the xreg. Everything seems to be working  
except when it goes to run my do* method, the Context is always empty  
so I can't seem to find a Portlet reference anywhere. I found a  
workaround my going to the Registry and hardcoding the name of the  
Portlet but this seems hack-ish.

Do I need to configure something to get the portlet stuck into the  
context? I've run the debugger and in the call stack above me, the  
context is always empty. It is working on the build* methods, just not  
the do* method. I've snipped the relevant fragments below.

-zoltan

=============================
the .xreg:

     <portlet-entry name="SharedStatePortlet" hidden="false" type="ref"
         parent="GenericMVCPortlet" application="false">
          
<classname>org.apache.jetspeed.portal.portlets.GenericMVCPortlet</ 
classname>
         <parameter name="template" value="sharedState.jsp" hidden="true"
             cachedOnName="true" cachedOnValue="true"/>
         <parameter name="action" value="portlets.SharedStateAction"
             hidden="true" cachedOnName="true" cachedOnValue="true"/>
         <parameter name="text" value="abc" hidden="false"
             cachedOnName="true" cachedOnValue="true"/>
         <media-type ref="html"/>
         <url cachedOnURL="true"/>
         <category group="Jetspeed">my.portlets</category>
     </portlet-entry>


=============================
the .jsp:

<%@ page language="java" session="false" %>
<%@ taglib uri='/WEB-INF/templates/jsp/tld/template.tld'  
prefix='jetspeed' %>
<p>
Shared State Portlet
<br/><br/>

The value of 'text' is: <%= request.getAttribute("text") %>
<form method="post" action="<jetspeed:dynamicUri/>">
<input type="hidden" name="js_peid" value="<%=  
request.getAttribute("js_peid") %>">
<input type="hidden" name="action" value="portlets.SharedStateAction"/>
<input type="text" name="text" value="<%= request.getAttribute("text")  
%>" />
<input type="submit" name="eventSubmit_doUpdate" value="Change"/>
</form>
</p>

=============================
the action:

public class SharedStateAction extends GenericMVCAction {

   protected void buildNormalContext(Portlet portlet, Context context,  
RunData runData) throws Exception {
     HttpServletRequest request = runData.getRequest();
     request.setAttribute("text",  
portlet.getPortletConfig().getInitParameter("text"));
   }
   public void doUpdate(RunData runData, Context context) {
     // would like to do this but context is always empty so where is  
the Portlet?
     //PortletConfigState.setPortletConfigParameter(portlet, "text",  
runData.getRequest().getParameter("text"));
     PortletEntry entry =  
(PortletEntry)Registry.getEntry(Registry.PORTLET, "SharedStatePortlet");
      
entry.getParameter("text").setValue(runData.getRequest().getParameter("t 
ext"));
   }

}


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org