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 Jeff Sheets <je...@gmail.com> on 2004/12/14 22:01:57 UTC
PortletRequest using struts portals bridge
Does anyone know how to get the PortletRequest from inside the struts
execute() method when using the struts portals bridge? I need to
access the PortletPreferences. I tried casting the HttpServletRequest
to a PortletRequest but that didn't work. Is it stored in the session
or elsewhere?
Thank you,
-- Jeff
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
Re: PortletRequest using struts portals bridge
Posted by Jeff Sheets <je...@gmail.com>.
Thank you both very much! I knew it had to be something simple...
These preferences are then stored in one of the Jetspeed 2 tables,
right? Even for Fusion?
-- Jeff
On Tue, 14 Dec 2004 23:22:59 +0100, Ate Douma <at...@douma.nu> wrote:
>
>
> Ate Douma wrote:
> > See Portlet Specification Chapter 16: Dispatching Requests to Servlets
> > and JSP
> >
> > PLT.16.3.2 Included Request A ttributes
> > In addition to the request attributes specified in Servlet Specification
> > 2.3, SRV.8.3.1
> > Section, the included servlet or JSP must have the following request
> > attributes set:
> > Request Attribute Type
> > javax.portlet.config javax.portlet.PortletConfig
> > javax.portlet.request javax.portlet.RenderRequest
> > javax.portlet.response javax.portlet.RenderResponse
> >
> > Example:
> > RenderRequest renderRequest =
> > (RenderRequest)servletRequest.getAttribute("javax.portlet.request");
>
> To add to the above: the Portlet spec only deals with dispatched requests
> to Servlets and JSP during the RenderRequest phase. But, using the Struts Bridge,
> Servlets (e.g. Struts) is also dispatched to during the ActionRequest phase.
>
> In the ActionRequest phase, the above example will result in a ClassCastException.
> To prevent that you can use the following generic solution:
>
> PortletRequest portletRequest = (PortletRequest)servletRequest.getAttribute("javax.portlet.request");
> if ( portletRequest instanceof ActionRequest ) {
> ActionRequest actionRequest = (ActionRequest)portletRequest;
> // do your actionRequest thing
> } else {
> RenderRequest renderRequest = (RenderRequest)portletRequest;
> // do your renderRequest thing
> }
>
> >
> > Jeff Sheets wrote:
> >
> >> Does anyone know how to get the PortletRequest from inside the struts
> >> execute() method when using the struts portals bridge? I need to
> >> access the PortletPreferences. I tried casting the HttpServletRequest
> >> to a PortletRequest but that didn't work. Is it stored in the session
> >> or elsewhere?
> >>
> >> Thank you,
> >> -- Jeff
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >> .
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
> >
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
Re: PortletRequest using struts portals bridge
Posted by Ate Douma <at...@douma.nu>.
Ate Douma wrote:
> See Portlet Specification Chapter 16: Dispatching Requests to Servlets
> and JSP
>
> PLT.16.3.2 Included Request A ttributes
> In addition to the request attributes specified in Servlet Specification
> 2.3, SRV.8.3.1
> Section, the included servlet or JSP must have the following request
> attributes set:
> Request Attribute Type
> javax.portlet.config javax.portlet.PortletConfig
> javax.portlet.request javax.portlet.RenderRequest
> javax.portlet.response javax.portlet.RenderResponse
>
> Example:
> RenderRequest renderRequest =
> (RenderRequest)servletRequest.getAttribute("javax.portlet.request");
To add to the above: the Portlet spec only deals with dispatched requests
to Servlets and JSP during the RenderRequest phase. But, using the Struts Bridge,
Servlets (e.g. Struts) is also dispatched to during the ActionRequest phase.
In the ActionRequest phase, the above example will result in a ClassCastException.
To prevent that you can use the following generic solution:
PortletRequest portletRequest = (PortletRequest)servletRequest.getAttribute("javax.portlet.request");
if ( portletRequest instanceof ActionRequest ) {
ActionRequest actionRequest = (ActionRequest)portletRequest;
// do your actionRequest thing
} else {
RenderRequest renderRequest = (RenderRequest)portletRequest;
// do your renderRequest thing
}
>
> Jeff Sheets wrote:
>
>> Does anyone know how to get the PortletRequest from inside the struts
>> execute() method when using the struts portals bridge? I need to
>> access the PortletPreferences. I tried casting the HttpServletRequest
>> to a PortletRequest but that didn't work. Is it stored in the session
>> or elsewhere?
>>
>> Thank you,
>> -- Jeff
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>>
>>
>>
>>
>> .
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
Re: PortletRequest using struts portals bridge
Posted by Ate Douma <at...@douma.nu>.
See Portlet Specification Chapter 16: Dispatching Requests to Servlets and JSP
PLT.16.3.2 Included Request A ttributes
In addition to the request attributes specified in Servlet Specification 2.3, SRV.8.3.1
Section, the included servlet or JSP must have the following request attributes set:
Request Attribute Type
javax.portlet.config javax.portlet.PortletConfig
javax.portlet.request javax.portlet.RenderRequest
javax.portlet.response javax.portlet.RenderResponse
Example:
RenderRequest renderRequest = (RenderRequest)servletRequest.getAttribute("javax.portlet.request");
Jeff Sheets wrote:
> Does anyone know how to get the PortletRequest from inside the struts
> execute() method when using the struts portals bridge? I need to
> access the PortletPreferences. I tried casting the HttpServletRequest
> to a PortletRequest but that didn't work. Is it stored in the session
> or elsewhere?
>
> Thank you,
> -- Jeff
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>
>
>
>
> .
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
Re: PortletRequest using struts portals bridge
Posted by "Scott T. Weaver" <sc...@binary-designs.net>.
HttpServletRequest.getAttribute("javax.portlet.request")
Jeff Sheets wrote:
>Does anyone know how to get the PortletRequest from inside the struts
>execute() method when using the struts portals bridge? I need to
>access the PortletPreferences. I tried casting the HttpServletRequest
>to a PortletRequest but that didn't work. Is it stored in the session
>or elsewhere?
>
>Thank you,
>-- Jeff
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>
>
>
>
>
--
"Great minds discuss ideas. Average minds discuss events. Small minds discuss people." - Admiral Hyman Rickover
*******************************************
* Scott T. Weaver *
* <we...@apache.org> *
* <http://www.einnovation.com> *
* -------------------------------------- *
* Apache Jetspeed Enterprise Portal *
* Apache Pluto Portlet Container *
* *
* OpenEdit, Website Content Management *
* <http://www.openedit.org> *
*******************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org