struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Nenning <Christoph.Nenn...@lex-com.net>
Subject Re: Implementing "cancel" on a form
Date Mon, 05 Oct 2015 13:10:40 GMT
Christopher,

> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA256
> >
> > All,
> >
> > I've got a form which works nicely, and I'd like to add a "cancel"
> > button to it. Right now, I have an Action class that implements no
> > Struts2-defined interfaces... I just have the typical execute-style
> > methods edit() and save(). I'd like to call cancel() when the user
> > presses the cancel button.
> >
> > I've been both reading "Struts 2 in Action" and doing a bit of
> > Googling, but it's tough to find resources on implementing "cancel".
> >
> > I did see something about using a button with a name like
> > "redirect-action:index" but it wasn't clear when that redirection
> > takes place... before or after the action is invoked.
> >
> > What am I missing?
> 
> You can use DMI (you must enable it first) and then you can use one of
> those solution
> 
> https://struts.apache.org/docs/html-form-buttons-howto.html
> https://struts.apache.org/docs/multiple-submit-buttons.html
> 
> basically:
> <s:submit method="cancel" value="Cancel"/>
> 
> 

Another option would be to register cancel() as a dedicated action:

http://struts.apache.org/docs/action-configuration.html#ActionConfiguration-ActionMethods

Then you would need another (non-visible) form with an according action 
attribute.



But as cancel should not change server state or involve Database 
operations I would rather use a link (styled as button) instead of 
submitting a form. That gives you just a GET request while a form submit 
usually means a POST-Redirect-GET cycle.


Regards,
Christoph


This Email was scanned by Sophos Anti Virus

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message