It's not a secret anymore!*
The moose likes Struts and the fly likes html tag cancel action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html tag cancel action" Watch "html tag cancel action" New topic
Author

html tag cancel action

David Heffington
Greenhorn

Joined: Mar 17, 2007
Posts: 17
Hi-
I am attempting to implement the cancel action via the html:cancel tag and an org.apache.struts.action.InvalidCancelException occurs when the cancel button is pressed. Here is what I have added:


In the HTML page:
<html:form action="/formTest">
.
.
.
<html:submit property="submitButton" value="Sumbit"/>
<html:cancel value="Cancel"/>
</html:form>


In the struts-config.xml:
<action-mappings>
<action path="/goFormData1" forward="/JSP/formData1.jsp" />

<action path="/formTest"
name="formOne"
validate="true"
input="/JSP/formData1.jsp"
scope="request"
type="cpa.app.fiscal.blah.actions.TestFormAction">
<forward name="formTest.cancel" path="/JSP/home.jsp"/>
<forward name="formTest.success" path="/JSP/formResults.jsp"/>
</action>
</action-mappings>


In the TestFormAction class:
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
if ( this.isCancelled( request ) )
{
System.out.println( "About to forward the cancel!" );
return mapping.findForward( "formTest.cancel" );
}
else
return mapping.findForward( "formTest.success" );
}
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In Struts version 1.2.9 and above, you will get this error unless you specify cancellable="true" in the action path definition in your struts-config.xml file. Since the cancel action bypasses validation, this was a security hole. Now it only works if you specifically configur it to work.


Merrill
Consultant, Sima Solutions
David Heffington
Greenhorn

Joined: Mar 17, 2007
Posts: 17
Cool! That fixed it. I am using an 'A Tutorial' book that covers version 1.2.

Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html tag cancel action
 
Similar Threads
html:select problem
How to use Cancel button in DispatchAction
LookupDispatchAction Query
DispatchAction not working as desired
MappingDispatchAction's JSP CODE