You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Kofford, C Todd" <tk...@ku.edu> on 2010/03/15 16:19:51 UTC

Cancel-Redirect Action not working on Portlet

I am using Struts 2.1.8.1 with the portlet plug-in, and my webapp, a
simple album database, is deployed on a tomcat 6 container.

When running this webapp stand-alone the cancel button action correctly
fires and calls the "cancelAlbum" action, but when running the same
webapp as a portlet in uPortal 3.1.2, the cancel button fires the action
defined for the form, "saveAlbum", not the redirected one that I defined
in the submit tag for the cancel button.

I have the following form defined in a JSP, for adding/editing an album:

<s:form action="saveAlbum" method="post">
  <s:textfield name="album.artist" label="%{getText('label.artist')}"
size="40"/>
  <s:textfield name="album.title" label="%{getText('label.title')}"
size="40"/>
  <s:textfield name="album.releaseYear"
label="%{getText('label.releaseYear')}" size="20"/>
  <s:select name="album.genre.genreId" list="genres" listKey="genreId"
listValue="name"/>
  <s:hidden name="album.albumId"/>
  <s:submit value="%{getText('button.label.submit')}"/> 
  <s:submit value="%{getText('button.label.cancel')}"
name="redirectAction:cancelAlbum"/>
</s:form>

I have the following actions defined in my struts.xml file, and my
action class, AlbumAction, implements the methods (list(), save(),
delete(), input(), cancel()):

    <package name="portlet-default" extends="struts-portlet-default"
namespace="/portlet">		
        <action name="index"
class="edu.ku.it.si.struts2portlet.action.AlbumAction" method="list">
            <result name="success">/jsp/albums.jsp</result>
        </action>
        
        <action name="*Album"
class="edu.ku.it.si.struts2portlet.action.AlbumAction" method="{1}">
            <result name="success">/jsp/albums.jsp</result>
            <result name="input">/jsp/albumForm.jsp</result>
            <result name="cancel">/jsp/albums.jsp</result>
            <result name="error">/jsp/error.jsp</result>
        </action>
    </package>

Anyone have any ideas why 
  <s:submit value="%{getText('button.label.cancel')}"
name="redirectAction:cancelAlbum"/> 
is not working for a portlet?
 
Thanks in advance,

Todd Kofford 
tkofford@ku.edu 
University of Kansas - IT 


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


RE: Cancel-Redirect Action not working on Portlet

Posted by "Kofford, C Todd" <tk...@ku.edu>.
I fixed this issue by changing my "Cancel" (submit) button to use the
"action" attribute for a cancel action, see change below. Sharing just
in case someone else runs into this issue.

Previously
-----------
<s:submit value="Cancel" name="redirectAction:cancelAlbum"/>

Fixed
------
<s:submit value="Cancel" action="cancelAlbum"/>


Todd Kofford 
tkofford@ku.edu 
University of Kansas - IT 


-----Original Message-----
From: Kofford, C Todd [mailto:tkofford@ku.edu] 
Sent: Monday, March 15, 2010 10:20 AM
To: user@struts.apache.org
Subject: Cancel-Redirect Action not working on Portlet

I am using Struts 2.1.8.1 with the portlet plug-in, and my webapp, a
simple album database, is deployed on a tomcat 6 container.

When running this webapp stand-alone the cancel button action correctly
fires and calls the "cancelAlbum" action, but when running the same
webapp as a portlet in uPortal 3.1.2, the cancel button fires the action
defined for the form, "saveAlbum", not the redirected one that I defined
in the submit tag for the cancel button.

I have the following form defined in a JSP, for adding/editing an album:

<s:form action="saveAlbum" method="post">
  <s:textfield name="album.artist" label="%{getText('label.artist')}"
size="40"/>
  <s:textfield name="album.title" label="%{getText('label.title')}"
size="40"/>
  <s:textfield name="album.releaseYear"
label="%{getText('label.releaseYear')}" size="20"/>
  <s:select name="album.genre.genreId" list="genres" listKey="genreId"
listValue="name"/>
  <s:hidden name="album.albumId"/>
  <s:submit value="%{getText('button.label.submit')}"/> 
  <s:submit value="%{getText('button.label.cancel')}"
name="redirectAction:cancelAlbum"/>
</s:form>

I have the following actions defined in my struts.xml file, and my
action class, AlbumAction, implements the methods (list(), save(),
delete(), input(), cancel()):

    <package name="portlet-default" extends="struts-portlet-default"
namespace="/portlet">		
        <action name="index"
class="edu.ku.it.si.struts2portlet.action.AlbumAction" method="list">
            <result name="success">/jsp/albums.jsp</result>
        </action>
        
        <action name="*Album"
class="edu.ku.it.si.struts2portlet.action.AlbumAction" method="{1}">
            <result name="success">/jsp/albums.jsp</result>
            <result name="input">/jsp/albumForm.jsp</result>
            <result name="cancel">/jsp/albums.jsp</result>
            <result name="error">/jsp/error.jsp</result>
        </action>
    </package>

Anyone have any ideas why 
  <s:submit value="%{getText('button.label.cancel')}"
name="redirectAction:cancelAlbum"/> 
is not working for a portlet?
 
Thanks in advance,

Todd Kofford 
tkofford@ku.edu 
University of Kansas - IT 


---------------------------------------------------------------------
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