Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

html tag cancel action

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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" );
}
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
David Heffington
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool! That fixed it. I am using an 'A Tutorial' book that covers version 1.2.

Thanks!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic