-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Martin,

On 10/4/15 7:40 PM, Martin Gainty wrote:
> by form you mean Struts 1.3 StrutsForm?

No, an S2 form. I'm sorry I wasn't specific, though it should have
been obvious since I mentioned I was reading "Struts /2/ in Action".

I'm just talking about an HTML <form>, not formal class called a Form
or anything like that.

> if your form class extends ActionForm then implement reset as seen
> here: public FooActionForm extends
> org.apache.struts.action.ActionForm { @Override public void
> reset(org.apache.struts.action.ActionMapping arg0, 
> HttpServletRequest arg1)  { arg1.getSession(false);.invalidate();
> //invalidate session } }

Logging the user out when they cancel a form seems rather drastic,
don't you think? Also, I don't think the above code does what you
think it does.

> <!-- struts.xml you define interceptor name and class for reset
> --> <interceptor name="actionForm-reset"
> class="org.apache.struts2.s1.ActionFormResetInterceptor"/> <include
> file="struts-integration.xml" />

Nope. If your examples are for Struts 1.3, there are no interceptors
available there.

> <!-- where struts-integration.xml would contain --> <struts> 
> <package name="integration" extends="struts1-default" 
> namespace="/integration"> <interceptor-stack name="integration"> 
> ....... <interceptor-ref name="actionForm-reset"/> <!-- pull
> interceptor for implementation of integration package --> ........ 
> </interceptor-stack> .... </struts>
> 
> <!-- Struts2 ..a somewhat different approach using a specific
> class which will implement button functionality --> 
> struts-validation.xml: <action name="cancelApplication" 
> class="org.apache.struts2.showcase.validation.SubmitApplication" 
> method="cancelApplication"> 
> <result>/validation/storeErrorsAcrossRequestCancel.jsp</result> 
> </action>
> 
> /validation/StoreErrorsAcrossRequestCancel.jsp: <html> <%@taglib
> prefix="s" uri="/struts-tags" %> <head><title>example of errors
> page</title></head> <body> <s:actionmessage/> <s:actionerror/> 
> <s:fielderror /> <h1>Application Canceled</h1> <s:url var="url" 
> value="/validation/storeErrorsAcrossRequestExample.jsp" /> <s:a
> href="%{#url}">Try Again</s:a> </body> </html>
> 
> you can also shortcut Cancel in jsp with 
> session.removeAttribute("fu");//clean out *all* session attribs 
> session.invalidate();                   //invalidate session

Yeah, none of that makes any sense.

What I've done in the meantime is a heavy-handed approach and written
my own interceptor:

  public String intercept(ActionInvocation actionInvocation)
    throws Exception
  {
    if(ActionContext.getContext().getParameters().containsKey(CANCEL_KEY
))
    {
      if(log.isDebugEnabled())
        log.debug("Form contains " + CANCEL_KEY
                  + " parameter; redirecting to "
                  + CANCEL_FORWARD + " forward");

      return CANCEL_FORWARD;
    }
    else
      return actionInvocation.invoke();
  }

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJWEgOLAAoJEBzwKT+lPKRYCW8QAJXVecgOl8oUM/vN8VnnwkUF
pSzN2UNGdjwsqbjLnS8Y5Ck59RpVTjrT0mrZKfsMA6iO1fCKEqPqLu/Oi3F+dwf7
kcqzJ8maVr2ttP1KUokHBX4xeL/JZJOImRT3iQiZ9dtPKm/uSsOrQxnhaz/8dqco
d2SQZSsLqc6mh01k6T2eTfmkk2KtuT4CloCiTsxmbtgkBs2wU44irdGtq9l1yTQE
LA62VgKJhMqzQ9dLsoisos+J0GMXb2On7fmoo5RI91ta1xPa3bX5c1+WrKqCilaZ
nnwV21cKpXLOEPbeZf8Ch0CkvxzVX5rqa+z02HQ08Q4fpSzo61lIb1+XsKaEFX0s
Nvz5mrjX5jrqgXqnvHejVqnggi1YVUlDwAI5wzDlss2CbNf6XT6wE8qLxsKQvuVt
6cqJmt3beRTOPN2pTebFvpSDZkJCWn+BmXLmzDV1G0s6MQZeQhN4R1UDj8FAjlQi
wAB82fLoLlvc5R9dekHSsA+DQvouQ1aoLGawxc4iz/Ky252z1sJbH+Q/yUcvI5U7
v2gqVEgH/oktq6TxLl45A5L9/IHu1wC/X9LfU0ywMnKGV+kLwSHw1xesqkBDuJSy
7/6Y073T19p1cIGgZpbCjJrYBCJV+ro8Rp37wDU3btQTBkop3MxOa8JTdpFGatcU
nEqRURGGlN2mdLKfd8xQ
=eq0t
-----END PGP SIGNATURE-----

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

Reply via email to