struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Lee" <brian_a_...@hotmail.com>
Subject RE: 2 submit buttons with different action
Date Tue, 24 Dec 2002 16:07:58 GMT
Have two submit buttons with different names and values.
Have a property for each in your form.
In your validate method check the value of each. Only the button that was 
clicked will have a nonnull value.

Example:
html:
<input type="submit" name="submit" value="foo">
<input type="submit" name="back" value="bar">

form class:
...
private String submit;
private String back;
...

validate method:
if ("foo".equals(getSubmit())){
//do validation
}else{        //getBack() should return null or empty string
//skip validation
}

I hope this helps.

BAL
> > > -----Message d'origine-----
> > > De : Ashish Kulkarni
> > [mailto:kulkarni_ash1312@yahoo.com]
> > > Envoye : mardi 24 decembre 2002 16:29
> > > A : Struts Users Mailing List
> > > Objet : 2 submit buttons with different action
> > >
> > >
> > > Hi,
> > >
> > > I have 2 buttons on one jsp, one is submit button
> > and
> > > the other is back. I want to use only one action
> > form
> > > to handle both the events, I am using
> > > DynaValidatorForm.
> > > So the problem i amfacing is, the fields get
> > validated
> > > even if i press the back button,
> > > Is there a way to make sure that the validation
> > occurs
> > > only when i press submit button
> > >
> > >
> > >
> > > =====
> > > A$HI$H


_________________________________________________________________
The new MSN 8: smart spam protection and 3 months FREE*.  
http://join.msn.com/?page=features/junkmail&xAPID=42&PS=47575&PI=7324&DI=7474&SU=

http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_smartspamprotection_3mf


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


Mime
View raw message