Good Afternoon April
First instinct is to put in some switch logic in your Actions perform
But then again I asked why is your cancel calling the wrong Action perform
method???
The cancel should forward to it's own Action class say CancelAction perform
method()
Since a page is worth a 1000 words I would urge your to Take a look at
Struts validation example available called Mailreader
http://luminal.gotdns.com/struts-mailreader/Tour.do
where the Initial screen login.jsp contains
<html:form action="/SubmitLogon" focus="username"
onsubmit="return validateLogonForm(this);">
<table border="0" width="100%">
Struts-config.xml contains the path /SubmitLogon which matches the parameter
for the form action from login.jsp
<action path="/SubmitLogon"
type="org.apache.struts.webapp.example.LogonAction"
name="LogonForm"
scope="request"
input="logon">
<exception
key="expired.password"
type="org.apache.struts.webapp.example.ExpiredPasswordException"
path="/ExpiredPassword.do"/>
</action>
The name LogonForm of our LogonAction class contains the form-bean
definition for LogonForm
Any validator will do you do not necessarily need a 'Dyna'Validator Form
<form-bean name="LogonForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="username" type="java.lang.String"/>
<form-property name="password" type="java.lang.String"/>
</form-bean>
The LogonForm identifies the criteria used for the validation-rules.xml
<form name="LogonForm">
<field property="username"
depends="required">
<arg0 key="prompt.username"/>
</field>
<field property="password"
depends="required, minlength,maxlength">
<arg0 key="prompt.password"/>
<arg1 key="${var:minlength}" name="minlength"
resource="false"/>
<arg2 key="${var:maxlength}" name="maxlength"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>16</var-value>
</var>
<var>
<var-name>minlength</var-name>
<var-value>3</var-value>
</var>
</field>
</form>
You will notice that Never at any time is cancel or reset forwarding to
LogonAction
I hope this helps you..
Martin-
----- Original Message -----
From: "April Francis" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Friday, October 28, 2005 4:01 PM
Subject: Re: Struts 1.1 and Validation
Martin Gainty <mgainty <at> hotmail.com> writes:
using html:cancel bypasses form bean validate method
http://struts.apache.org/struts-taglib/tagreference-struts-
html.html#cancelHTH-----
Original Message -----
From: "April Francis" <afrancis <at> bcbsok.com>
To: <user <at> struts.apache.org>
Sent: Friday, October 28, 2005 12:30 PM
Subject: Struts 1.1 and Validation
> On Struts 1.1, does the <html:cancel> tag work?
>
> Example:
> If I click on the cancel button below, will validation be ignored?
>
> <html:cancel onClick="bCancel=true;">
> <bean:message...../>
> <html:cancel>
>
> I have put the above in my jsp, but the struts validation still runs
> when
> I use
> the cancel button. I'm thinking maybe struts 1.1 doesn't have the
> necessary
> pieces in place???? If so, then how can I handle a cancel?
>
> thank you,
> April
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe <at> struts.apache.org
> For additional commands, e-mail: user-help <at> struts.apache.org
>
>
I even have this in my Action class and the validation still won't
bypass...
if (this.isCancelled(request))
....don't do anything, like saving the data....
isCancelled is always false even if I click on the cancel button
Is there some piece I'm missing? I want the cancel button to NOT run
through
validation...which is what it's suppose to do, but doesn't seem to work
for
me. Is there some trick?
One thing I did notice, in the 'Struts In Action' book, it talks about
having
the 'struts-validator.tld' file (pg 136, chapter 4). BUT the Struts 1.1
download does not have it. I've also seen other sites that say it is not
needed.
April
---------------------------------------------------------------------
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]