Thanks Claire,
Unfortunately in your example below, any changes made to the page before it
was submitted with the cancel button will actually change the values stored
on the form though.

-----Original Message-----
From: Claire Wall [mailto:[EMAIL PROTECTED]
Sent: 02 February 2004 09:42
To: Struts Users Mailing List
Subject: Re: How do you submit a page and not change values


you can use the <html:submit> and <html:cancel> buttons from within a form.
They will both actually submit the form to an action, but it is possible to
capture the 'cancel' event in your action and therefore forward the user to
different places depending upon which one they clicked on.

so, for example, say you had a form with one field called 'name' and two
buttons- one 'cancel' and one 'submit'...

<html:form action="/saveDetails">

<html:text name="DetailsForm" property="name"/>

<html:submit>Submit</html:submit>
<html:cancel>Cancel</html:cancel>

</html:form>

in struts-config you define your actions and where you wish to forward to
depending on which button the user clicked on:

  <action input="/xxx.jsp" name="DetailsForm" path="/saveDetails"
   scope="request" type="xxx.xxx.SaveDetailsAction" validate="false">
   <forward name="success" path="/xxx.jsp" />
    <forward name="cancel" path="/yyy.jsp" />
  </action>


and, finally, in your action you can catch the cancel event and forward to
the other place like so:

if(isCancelled(request))
{
    return mapping.findForward("cancel");
}

else
{
    return mapping.findForward("success");
}



I hope that this answers your question - if not then sorry if i am just
repeating stuff that you already know! :)

regards,
Claire :)

----- Original Message -----
From: "Hunt, Steve" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Monday, February 02, 2004 9:06 AM
Subject: How do you submit a page and not change values


> If you use either html:button, html:submit or html:cancel buttons they
> generate <input type="button"> html.
>
> So how can you create a screen for example with 1 field and 2 buttons, a
> submit and a do Not Submit button, both of which navigate the user to a
> results screen?
>
> Regards
> Steve
>
>
> =======================================================
> This message contains information that may be privileged or confidential
and is the property of the Cap Gemini Ernst & Young Group. It is intended
only for the person to whom it is addressed. If you are not the intended
recipient, you are not authorised to read, print, retain, copy, disseminate,
distribute, or use this message or any part thereof. If you receive this
message in error, please notify the sender immediately and delete all copies
of this message.
> =======================================================
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to