struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nils-Helge Garli Hegvik" <nil...@gmail.com>
Subject Re: struts2 redirect action
Date Tue, 15 Jan 2008 22:32:07 GMT
I think I have figured out the problem. The problem is that
"redirectAction" doesn't really do what you think it does, not when
used in the render phase. I should probably implement a check for
this, as you can't do a sendRedirect in a portlet. "redirectAction" in
a portlet should only be used after executing an action in the action
phase (I need to document this....). So...with that in mind, you
should change your configuration:

struts.xml

<action name="index"
class="com.cerner.healthe.health.management.vitals.action.IndexAction">
    <result name="advisor">/WEB-INF/view/advisor.jsp</result>
    <result name="consumer">/WEB-INF/view/consumer.jsp</result>
</action>

Then make sure you use the "redirectAction" result type only when your
action has been executed in the action phase (form submit, or s:url
created with the attribute 'portletUrlType' set to 'action').

Hope that made sense...

Nils-H

On Jan 15, 2008 8:45 PM, Brian Relph <relphie@gmail.com> wrote:
> I have debugged through my own code, but not too deeply through the struts2
> code.  I did notice when running it with struts 2.0.11, that there was a
> warning that the actionMapper property of the PortletActionRedirectResult
> was not set b/c the bean could not be found.
>
> Would something in the web.xml affect it?  I noticed in the portlet
> archetype, that it is empty.  I have included that as well.
>
>
> portlet.xml
> ----------------
> <?xml version="1.0" encoding="UTF-8"?>
>
> <portlet-app version="1.0" xmlns=
> http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd xmlns:xsi=
> http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation="
> http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
> http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
>  id="healthehealthmanagementvitals">
>
> <portlet id="HealtheHealthManagementVitals">
>
> <description xml:lang="EN">
> Healthe Health Management Vitals Portlet
> </description>
>
> <portlet-name>HealtheHealthManagementVitals</portlet-name>
>
> <display-name xml:lang="EN">HealtheHealthManagementVitals</display-name>
>
> <portlet-class>
> org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher
> </portlet-class>
>
> <!-- The namespace for the actions configured for view mode -->
> <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>
>
> <expiration-cache>0</expiration-cache>
>
> <supports>
>   <mime-type>text/html</mime-type>
>   <portlet-mode>view</portlet-mode>
> </supports>
>
> <supported-locale>en</supported-locale>
>
> <portlet-info>
>   <title>Healthe Health Management Vitals Portlet</title>
>   <short-title>HealtheHealthManagementVitals</short-title>
>   <keywords>struts 2,portlet,healthe,health,management,vitals</keywords>
> </portlet-info>
>
> <security-role-ref>
>   <role-name>Role_Consumers</role-name>
> </security-role-ref>
>
> </portlet>
>
> </portlet-app>
>
>
> web.xml
> ------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
> Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app id="healthe-health-management-vitals">
>
> <display-name>healthe-health-management-vitals-war</display-name>
>
> <context-param>
>   <param-name>contextConfigLocation</param-name>
>   <param-value>/WEB-INF/applicationContext*.xml</param-value>
> </context-param>
>
> <listener>
>   <listener-class>
>     org.springframework.web.context.ContextLoaderListener
>   </listener-class>
> </listener>
>
> <welcome-file-list>
>   <welcome-file>index.html</welcome-file>
>   <welcome-file>index.htm</welcome-file>
>   <welcome-file>index.jsp</welcome-file>
> </welcome-file-list>
>
> <security-constraint id="SecurityConstraint_1">
>   <web-resource-collection id="WebResourceCollection_1">
>     <web-resource-name>Healthe Health Management Vitals</web-resource-name>
>     <url-pattern>/HealtheHealthManagementVitals/*</url-pattern>
>   </web-resource-collection>
>   <auth-constraint id="AuthConstraint_1">
>     <role-name>Role_Consumers</role-name>
>   </auth-constraint>
> </security-constraint>
>
> <security-role>
>   <role-name>Role_Consumers</role-name>
> </security-role>
>
> </web-app>
>
>
>
> On 1/15/08, Nils-Helge Garli Hegvik <nilsga@gmail.com> wrote:
> >
> > Hm.... I usually experience this behaviour when the JSPs aren't
> > found... Other than that, redirectAction runs just fine in my sample
> > applications. Have you tried launching in debug mode and step through
> > the code? Can you show your portlet.xml file?
> >
> > Nils-H
> >
> > On Jan 15, 2008 7:58 PM, Brian Relph <relphie@gmail.com> wrote:
> > > My WEB-INF/index.jsp is used so that i can use the same installation as
> > both
> > > a portlet and a servlet.  Websphere comes with an embedded portlet
> > container
> > > as well as a servlet that can serve portlets as servlets, so i can
> > install
> > > my webapp a single time and have it accessible both in and out of my
> > portal.
> > >
> > > I may have led you astray by including that file in my post - the
> > redirect
> > > from there is working fine.  I am testing using the JettyPlutoLauncher
> > class
> > > and the maven-pluto-plugin / maven-jetty-plugin.  When accessing my
> > portlet
> > > at http://localhost/portlet/view/index, control goes into my index
> > action
> > > and i return "consumer" - the logs show:
> > >
> > > 5227707 [btpool0-1] DEBUG
> > > org.springframework.beans.factory.support.DefaultListableBeanFactory -
> > Bean
> > > 'org.apache.struts2.portlet.result.PortletActionRedirectResult'
> > instantiated
> > > via constructor [public
> > > org.apache.struts2.portlet.result.PortletActionRedirectResult()]
> > > 5227722 [btpool0-1] DEBUG
> > > com.opensymphony.xwork2.interceptor.I18nInterceptor - after Locale=en_US
> > > 5227722 [btpool0-1] DEBUG
> > > com.opensymphony.xwork2.interceptor.I18nInterceptor - intercept }
> > >
> > > but the page remains blank.
> > >
> > > If i instead access http://localhost/portlet/pluto/index.jsp, again,
> > control
> > > goes into my index action, i return "consumer" and the logs show:
> > >
> > > 316389 [btpool0-1] DEBUG
> > > org.springframework.beans.factory.support.DefaultListableBeanFactory -
> > Bean
> > > 'org.apache.struts2.portlet.result.PortletActionRedirectResult'
> > instantiated
> > > via constructor [public
> > > org.apache.struts2.portlet.result.PortletActionRedirectResult()]
> > > 5316389 [btpool0-1] DEBUG
> > org.apache.struts2.portlet.result.PortletResult -
> > > Executing result in Render phase
> > > 5316389 [btpool0-1] DEBUG
> > org.apache.pluto.internal.impl.PortletEntityImpl -
> > > Retrieved cross context: ServletContext@7bca7bca{
> > >
> > /portlet,file:/C:/workspaces/hin-portal-test/healthe-health-management-vitals/src/main/webapp/}
> > > 5316389 [btpool0-1] DEBUG
> > org.apache.struts2.portlet.result.PortletResult -
> > > Location: /view/consumerView.action
> > > 5316389 [btpool0-1] DEBUG
> > > org.apache.pluto.internal.impl.PortletContextImpl-
> > > PortletRequestDispatcher requested: /view/consumerView.action
> > > 5316389 [btpool0-1] DEBUG
> > > org.apache.pluto.internal.impl.PortletRequestDispatcherImpl - Named
> > > dispatcher created.
> > > 5316389 [btpool0-1] DEBUG
> > > org.apache.pluto.internal.impl.PortletRequestDispatcherImpl - Request
> > > dispatcher created.
> > > 5316389 [btpool0-1] DEBUG
> > org.apache.pluto.internal.impl.RenderRequestImpl -
> > > Render request's included mode: true
> > > 5316389 [btpool0-1] DEBUG
> > org.apache.pluto.internal.impl.RenderRequestImpl -
> > > No query string appended to the included request.
> > > 5316405 [btpool0-1] WARN com.opensymphony.xwork2.ognl.OgnlValueStack -
> > Could
> > > not find property
> > >
> > [Pluto_/portlet.HealtheHealthManagementVitals!_org.mortbay.jetty.included]
> > > 5316405 [btpool0-1] DEBUG
> > org.apache.pluto.internal.impl.RenderRequestImpl -
> > > Render request's included mode: false
> > > 5316405 [btpool0-1] DEBUG
> > > com.opensymphony.xwork2.interceptor.I18nInterceptor - after Locale=en_US
> > > 5316405 [btpool0-1] DEBUG
> > > com.opensymphony.xwork2.interceptor.I18nInterceptor - intercept }
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher - Leaving render
> > > 5316405 [btpool0-1] DEBUG org.apache.pluto.core.PortletContainerImpl -
> > > Portlet Container [Pluto Portal Driver]: Portlet rendered for:
> > > HealtheHealthManagementVitals
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletModeAnchorTag- Evaluated portletId
> > > to: /portlet.HealtheHealthManagementVitals!
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletModeAnchorTag- Testing if
> > > PortletWindowConfig [/portlet.HealtheHealthManagementVitals!]
> > > supports mode [view]
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletModeAnchorTag- Evaluated portletId
> > > to: /portlet.HealtheHealthManagementVitals!
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletModeAnchorTag- Testing if
> > > PortletWindowConfig [/portlet.HealtheHealthManagementVitals!]
> > > supports mode [edit]
> > > 5316405 [btpool0-1] INFO
> > > org.apache.pluto.driver.services.impl.resource.SupportedModesServiceImpl-
> > > Portlet mode 'edit' not found for portletId:
> > > '/portlet.HealtheHealthManagementVitals!'
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletModeAnchorTag- Evaluated portletId
> > > to: /portlet.HealtheHealthManagementVitals!
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletModeAnchorTag- Testing if
> > > PortletWindowConfig [/portlet.HealtheHealthManagementVitals!]
> > > supports mode [help]
> > > 5316405 [btpool0-1] INFO
> > > org.apache.pluto.driver.services.impl.resource.SupportedModesServiceImpl-
> > > Portlet mode 'help' not found for portletId:
> > > '/portlet.HealtheHealthManagementVitals!'
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletWindowStateAnchorTag - Evaluated
> > > portletId to: /portlet.HealtheHealthManagementVitals!
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletWindowStateAnchorTag - Testing if
> > > PortletWindowConfig [/portlet.HealtheHealthManagementVitals!] supports
> > > window state [minimized]
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletWindowStateAnchorTag - Evaluated
> > > portletId to: /portlet.HealtheHealthManagementVitals!
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletWindowStateAnchorTag - Testing if
> > > PortletWindowConfig [/portlet.HealtheHealthManagementVitals!] supports
> > > window state [maximized]
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletWindowStateAnchorTag - Evaluated
> > > portletId to: /portlet.HealtheHealthManagementVitals!
> > > 5316405 [btpool0-1] DEBUG
> > > org.apache.pluto.driver.tags.PortletWindowStateAnchorTag - Testing if
> > > PortletWindowConfig [/portlet.HealtheHealthManagementVitals!]
> > > supports window state [normal]
> > > In this case, the Pluto portal is shown with a portlet that has no
> > content.
> > > (the body div is completely empty, but the head div does have the
> > portlet
> > > name).
> > >
> > > As well, consumerView.action render result does not pass control into
> > the
> > > action itself.
> > >
> > >
> > >
> > > On 1/15/08, Nils-Helge Garli Hegvik <nilsga@gmail.com> wrote:
> > >
> > > > Are you running this in a portlet container? Your index.jsp and the
> > > > redirect url does not make sense i a portal server (unless you are
> > > > embedding it in some way....)? Please provide some more information.
> > > >
> > > > Nils-H
> > > >
> > > > On Jan 15, 2008 6:38 PM, Brian Relph <relphie@gmail.com> wrote:
> > > > > I am having trouble getting a redirectAction to work.  I am using
> > > > > struts2-portlet-plugin-2.1.1-SNAPSHOT, i have also tried using
> > > > > struts-2.0.11with no luck.  Any advice?  Here are my configs:
> > > > >
> > > > > WEB-INF/index.jsp
> > > > > ----------------------------
> > > > > <%
> > > > > String redirectURL = "view/index.action";
> > > > > response.sendRedirect(redirectURL);
> > > > > %>
> > > > >
> > > > >
> > > > > struts.xml
> > > > > ---------------
> > > > > <struts>
> > > > >
> > > > > <include file="struts-portlet-default.xml" />
> > > > >
> > > > > <package name="default" extends="struts-portlet-default"
> > > > namespace="/view">
> > > > >
> > > > >   <action name="index" class="
> > > > > com.health.management.vitals.action.IndexAction">
> > > > >     <result name="advisor" type="redirectAction">
> > > > >       <param name="actionName">advisorView</param>
> > > > >     </result>
> > > > >     <result name="consumer" type="redirectAction">
> > > > >       <param name="actionName">consumerView</param>
> > > > >     </result>
> > > > >   </action>
> > > > >
> > > > >   <action name="advisorView" class="
> > > > > com.health.management.vitals.action.AdvisorViewAction">
> > > > >     <result>/WEB-INF/view/advisor.jsp</result>
> > > > >   </action>
> > > > >
> > > > >   <action name="consumerView" class="
> > > > > com.health.management.vitals.action.ConsumerViewAction">
> > > > >     <result>/WEB-INF/view/consumer.jsp</result>
> > > > >   </action>
> > > > >
> > > > > </package>
> > > > >
> > > > > </struts>
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

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


Mime
View raw message