Jonathan Hawkins said:
> Ate,
>
> I\'ve built the latest portals-bridges-struts-1.2.7-0.4-SNAPSHOT.jar and
> deployed it in my webapp.
>
> I\'m using Eclipse to step through the code. This is my Execute method :-
>
> public ActionForward execute(ActionMapping mapping, ActionForm form,
>    HttpServletRequest request, HttpServletResponse response) {
>   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\");
>  }
>
> actionRequest is always coming back as null, if I take a look at the
> attributes that are set within the HttpServletRequest, the only ones I can
> see being set are :-
>
> org.apache.struts.action.MESSAGE
>
> org.apache.struts.action.mapping.instance
>
> org.apache.struts.action.MODULE
>
> no sign of javax.portlet.request.
>
> This is driving me round the bend !!!!!
>
That is very strange.
Could you provide the full stacktrace of the call to your execute method?

Note: on line 354 of the StrutsPortlet.java the javax.portlet.request
attribute is/should be set.

Ate
>
>
> Any further assistance would be greatly appreciated, examples or
> otherwise.
>
>
>
> Jonathan
>
>
>
>
>
> ________________________________
>
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Wed 19/10/2005 13:34
> To: [email protected]
> Cc: [EMAIL PROTECTED]; [email protected]
> Subject: Re: Struts Bridge and Inter Portlet Communication
>
>
>
> Thanks Ate,
>
> I was getting null pointer exceptions. I\'ll subscribe to the other list as
> well andbuild the struts bridge and see what I can get hold of this time.
>
> I\'ve created my own constants file with an entry for
> javax.portlet.request.
>
> All assistance is very much appreciated.
>
> Jonathan
>
>
>> Jonathan,
>> First of all, I cc\'d this to the bridges-user mailing list so we can
>> continue the discussion there.
>> (if you haven\'t subscribed yet:
>> http://portals.apache.org/bridges/mail-lists.html)
>>
>> It is not clear to me *what* is not working with the example you
>> provided. Do you get an exception/stacktrace or is the
>> ContainerConstants.PORTLET_REQUEST not set?
>>
>> In the latter case, it might be a case of which version of the
>> struts-bridge you are using. Since august 8, the struts-bridge trunk
>> now *does* provide the \"javax.portlet.request\" attribute, even when
>> accessed from an ActionRequest. See:
>> http://issues.apache.org/jira/browse/PB-2.
>> To be able to use it, you need to checkout and build the bridges
>> yourself.
>>
>> If you get an exception, could you please provide that?
>>
>> Note: Using ContainerConstants.PORTLET_REQUEST (instead of
>> \"javax.portlet.request\") binds you to the jetspeed-commons jar. If you
>> really want to be JSR-168 compliant, you should *not* use
>> jetspeed-commons.
>>
>> Regards,
>>
>> Ate
>>
>>
>> [EMAIL PROTECTED] wrote:
>>> 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]
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
> This email and any files transmitted with it are confidential
> and intended solely for the use of the individual or entity to
> whom they are addressed. Any unauthorised distribution or
> copying is strictly prohibited. Whilst CedarOpenAccounts
> takes steps to prevent the transmission of viruses via e-mail,
> we cannot guarantee that any email or attachment is free from
> computer viruses and you are strongly advised to undertake your
> own anti-virus precautions. CedarOpenAccounts grants no
> warranties regarding performance, use or quality of any e-mail
> or attachment and undertakes no liability for loss or damage,
> howsoever caused.
>
> CedarOpenAccounts is a trading name of Cedar Software Ltd and
> OpenAccounts Ltd.
>
> For more information on CedarOpenAccounts and our products,
> please visit our web site at http://www.cedaropenaccounts.com
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to