> Date: Fri, 21 Mar 2014 14:58:21 -0700
> Subject: javax.portlet.ResourceResponse reference in Action
> From: [email protected]
> To: [email protected]
>
> Hello All
>
> What is the recommended way of getting ResourceResponse instance in the
> action method of JSR 286 based Struts2 Portlet Action class? I'm using
> following way :
>
> ResourceResponse response =
> (ResourceResponse)PortletActionContext.getResponse();
>
> As PortletActionContext doesn't provide method to get ResourceResponse
> instance. Am I missing something here?
MG>ActtionContext is set to null as seen here in Jsr286Dispatcher (processEvent)
Jsr286Dispatcher::processEvent(EventRequest request, EventResponse response)
throws PortletException, IOException
{
ActionContext.setContext(null);
}
..later on Jsr286Dispatcher has override for createPortlerServletResponse..
@Override
protected PortletServletResponse createPortletServletResponse(PortletResponse
response)
{
return new PortletServletResponseJSR286(response);
}
MG>
portlet.xml invokes Jsr286Dispatcher
<portlet id="StrutsPortlet2">
<description xml:lang="EN">Struts Test Portlet with JSR 286
Dispatcher</description>
<portlet-name>StrutsPortlet2</portlet-name>
<display-name xml:lang="EN">Struts Test Portlet with JSR 286
Dispatcher</display-name>
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
<!-- The view mode namespace. Maps to a namespace in the Struts 2
config file. -->
<init-param>
<name>viewNamespace</name>
<value>/view</value>
</init-param>
<!-- The default action to invoke in view mode. -->
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
<!-- The edit mode namespace. Maps to a namespace in the Struts 2
config file. -->
<init-param>
<name>editNamespace</name>
<value>/edit</value>
</init-param>
<!-- The default action to invoke in edit mode. -->
<init-param>
<name>defaultEditAction</name>
<value>index</value>
</init-param>
<!-- The help mode namespace. Maps to a namespace in the Struts 2
config file. -->
<init-param>
<name>helpNamespace</name>
<value>/help</value>
</init-param>
<!-- The default action to invoke in help mode. -->
<init-param>
<name>defaultHelpAction</name>
<value>index</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>My Struts2 Portlet with JSR 286 Dispatcher</title>
<short-title>SP2JSR286</short-title>
<keywords>struts,portlet</keywords>
</portlet-info>
</portlet>
MG>land on /view in Struts webapp and you should get
PortletServletResponseJSR286
MG>is this not the case?
>
> *Thanks & Regards/ **सादर**,*
> *Gaurav Daga*
> *[email protected] <[email protected]> | +1.201.308.3242 | Web
> Presence <http://goo.gl/lW0nh> *
> Do not follow where the path may lead. Go instead where there is no path
> and leave a trail. - Harold R. McAlindon