You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Gaurav Daga <to...@gmail.com> on 2014/03/21 22:58:21 UTC

javax.portlet.ResourceResponse reference in Action

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?

*Thanks & Regards/ **सादर**,*
*Gaurav Daga*
*togauravdaga@gmail.com <to...@gmail.com> | +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

RE: javax.portlet.ResourceResponse reference in Action

Posted by Martin Gainty <mg...@hotmail.com>.
  


> Date: Fri, 21 Mar 2014 14:58:21 -0700
> Subject: javax.portlet.ResourceResponse reference in Action
> From: togauravdaga@gmail.com
> To: dev@struts.apache.org
> 
> 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*
> *togauravdaga@gmail.com <to...@gmail.com> | +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