struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claire Wall" <claire.w...@kurtosys.com>
Subject Re: How do you submit a page and not change values
Date Mon, 02 Feb 2004 09:42:27 GMT
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" <steve.hunt@cgey.com>
To: "'Struts Users Mailing List'" <struts-user@jakarta.apache.org>
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: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>



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


Mime
View raw message