You cant navigate to another page without a proper submit (for example, to cancel and return to a calling page). This is why immediate is preferred to skip updating the backing bean, but to invoke a bound action anyway.
The type="button" option is meant for "plain" buttons to invoke client-side javascript. It is therefore bad practise to use it as a Cancel button, not to mention semantically misleading. It should be remembered, of course, that once properly considered, use whatever works for you in your scenario. Dhanji. -----Original Message----- From: Chandra Sekhar [mailto:[EMAIL PROTECTED] Sent: Tuesday, 25 July 2006 2:43 PM To: MyFaces Discussion Subject: Re: how do you folks handle a "Cancel" button? Hi, When type = "button" is given <h:commandButton> will act as html button , and a necessary javaScript function wcan be called on an event. So there is no point of going upto the bean. It can be handled at the JSP Side alone. If there are any other specific reasons for immedieate = "true" please mention it. Rgds, Chandru. ----- Original Message ----- From: "Dhananjay Prasanna" <[EMAIL PROTECTED]> To: "MyFaces Discussion" <users@myfaces.apache.org> Sent: Tuesday, July 25, 2006 10:03 AM Subject: RE: how do you folks handle a "Cancel" button? > > I believe the preferred way is to set the attribute, immediate="true" on > the button, so that the POST contents are not merged into the backing > bean. > > -----Original Message----- > From: Chandra Sekhar [mailto:[EMAIL PROTECTED] > Sent: Tuesday, 25 July 2006 2:32 PM > To: MyFaces Discussion > Subject: Re: how do you folks handle a "Cancel" button? > > Instead you can do it as type = "button" in the <h:commandButton> , > then > it will function as a normal Button. > > Chandru. > > ----- Original Message ----- > From: "Julian Ray" <[EMAIL PROTECTED]> > To: "'MyFaces Discussion'" <users@myfaces.apache.org> > Sent: Tuesday, July 25, 2006 2:12 AM > Subject: RE: how do you folks handle a "Cancel" button? > > >> Add immediate="true" to the command button. This will by pass any > updates. >> >> >> -----Original Message----- >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >> Sent: Monday, July 24, 2006 4:37 PM >> To: MyFaces Discussion >> Subject: how do you folks handle a "Cancel" button? >> >> >> >> >> >> >> hello to everyone, >> >> I have a form that displays detail data from a backing bean. >> >> The same bean supplies properties for an update page. >> >> The update page has a Cancel button and when selected should return > the >> user >> to the detail page with no changes saved. >> >> Simple enough use, but when the Cancel button is selected, the backing > >> bean >> is updated and the detail page shows modified data. >> >> How do you folks handle similar situations? >> >> Thanks in advance for your help. >> Tom >> >> >> >> >> This message is intended for the recipient only and is not meant to be >> forwarded or distributed in any other format. This communication is > for >> informational purposes only. It is not intended as an offer or >> solicitation >> for the purchase or sale of any financial instrument, or security, or > as >> an >> official confirmation of any transaction. Putnam does not accept > purchase >> or redemptions of securities, instructions, or authorizations that are > >> sent >> via e-mail. All market prices, data and other information are not >> warranted as to completeness or accuracy and are subject to change > without >> notice. Any comments or statements made herein do not necessarily > reflect >> those of Putnam, LLC (DBA Putnam Investments) and its subsidiaries and >> affiliates. If you are not the intended recipient of this e-mail, > please >> delete the e-mail. > > > This correspondence is for the named persons only. > It may contain confidential or privileged information or both. > No confidentiality or privilege is waived or lost by any mis transmission. > If you receive this correspondence in error please delete it from your > system immediately and notify the sender. > You must not disclose, copy or relay on any part of this correspondence, > if you are not the intended recipient. > Any opinions expressed in this message are those of the individual sender > except where the sender expressly, > and with the authority, states them to be the opinions of the Department > of Emergency Services, Queensland. This correspondence is for the named persons only. It may contain confidential or privileged information or both. No confidentiality or privilege is waived or lost by any mis transmission. If you receive this correspondence in error please delete it from your system immediately and notify the sender. You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient. Any opinions expressed in this message are those of the individual sender except where the sender expressly, and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.