You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anjib Mulepati <an...@hotmail.com> on 2010/12/28 19:20:23 UTC

Using validate.xml and validate()

Struts 1.3.8

Can I use validate.xml and validate() method at same time

a) for same field in both place and
b) different disjunctive fields.

Anjib

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


Re: Using validate.xml and validate()

Posted by Paul Benedict <pb...@apache.org>.
Yes. You need to extend ValidatorForm (or ValidatorActionForm) to override
the validate() method.

On Tue, Dec 28, 2010 at 1:55 PM, Anjib Mulepati <an...@hotmail.com> wrote:

> So my form should extends from ValidatorForm?
> Anjib
>
> On 12/28/2010 2:50 PM, Paul Benedict wrote:
>
>> Option 2 is fine.
>>
>> On Tue, Dec 28, 2010 at 1:45 PM, Anjib Mulepati<an...@hotmail.com>
>>  wrote:
>>
>>  1. Complex in the sense my own custom validation for multiple emails.
>>> 2. So do you mean i can go with Option 2?
>>>
>>> Anjib
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Using validate.xml and validate()

Posted by Anjib Mulepati <an...@hotmail.com>.
So my form should extends from ValidatorForm?
Anjib
On 12/28/2010 2:50 PM, Paul Benedict wrote:
> Option 2 is fine.
>
> On Tue, Dec 28, 2010 at 1:45 PM, Anjib Mulepati<an...@hotmail.com>  wrote:
>
>> 1. Complex in the sense my own custom validation for multiple emails.
>> 2. So do you mean i can go with Option 2?
>>
>> Anjib
>>
>>


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


Re: Using validate.xml and validate()

Posted by Paul Benedict <pb...@apache.org>.
Option 2 is fine.

On Tue, Dec 28, 2010 at 1:45 PM, Anjib Mulepati <an...@hotmail.com> wrote:

> 1. Complex in the sense my own custom validation for multiple emails.
> 2. So do you mean i can go with Option 2?
>
> Anjib
>
>

Re: Using validate.xml and validate()

Posted by Anjib Mulepati <an...@hotmail.com>.
1. Complex in the sense my own custom validation for multiple emails.
2. So do you mean i can go with Option 2?

Anjib


On 12/28/2010 2:38 PM, Paul Benedict wrote:
> On Tue, Dec 28, 2010 at 12:43 PM, Anjib Mulepati<an...@hotmail.com>wrote:
>
>> Ok to make my self clear I have three field to check name,email and
>> message.
>> I want name and message to be required but email required complex
>> validation that is not provided with struts.
>>
> What kind of "complex" validation?
>
>
>> As 'required' is provided in Struts I can set validation rule for name and
>> message simply in xml file.
>> And i want to write validation rule for email in validate() method.
>> Is that possible?
>>
>>
> Yes. My apologies for misunderstanding. If you override validate() on your
> Form bean, you can do whatever else you want to do.
>
> Paul
>


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


Re: Using validate.xml and validate()

Posted by Paul Benedict <pb...@apache.org>.
On Tue, Dec 28, 2010 at 12:43 PM, Anjib Mulepati <an...@hotmail.com>wrote:

> Ok to make my self clear I have three field to check name,email and
> message.
> I want name and message to be required but email required complex
> validation that is not provided with struts.
>

What kind of "complex" validation?


> As 'required' is provided in Struts I can set validation rule for name and
> message simply in xml file.
> And i want to write validation rule for email in validate() method.
> Is that possible?
>
>
Yes. My apologies for misunderstanding. If you override validate() on your
Form bean, you can do whatever else you want to do.

Paul

Re: Using validate.xml and validate()

Posted by Anjib Mulepati <an...@hotmail.com>.
Ok to make my self clear I have three field to check name,email and message.
I want name and message to be required but email required complex 
validation that is not provided with struts.
As 'required' is provided in Struts I can set validation rule for name 
and message simply in xml file.
And i want to write validation rule for email in validate() method.
Is that possible?

Also one step further can i define rule for name and message in 
validate() method also?

Field              Validation
-------------------------------
Name            Required
Email            Complex
Message       Required

Option 1:
-------------
In .xml file
<rule for name required/>
<rule for message required/>

and in validate() method
{  //rule for email check }

Option 2:
-------------
In .xml file
<rule for name required/>
<rule for message required/>

and in validate() method
{// rule for name required }
{// rule for message required}
{// rule for email check }

If both option is not possible what can I do?

Anjib





On 12/28/2010 1:27 PM, Paul Benedict wrote:
> Anjib,
>
> It depends on how you configure your struts action. If you have
> validate="true" on, then no -- failed validation will never make it to your
> action. If you want to call validate() yourself in execute() and perform
> additional validation, go for it.
>
> Paul
>
> On Tue, Dec 28, 2010 at 12:20 PM, Anjib Mulepati<an...@hotmail.com>wrote:
>
>> Struts 1.3.8
>>
>> Can I use validate.xml and validate() method at same time
>>
>> a) for same field in both place and
>> b) different disjunctive fields.
>>
>> Anjib
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


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


Re: Using validate.xml and validate()

Posted by Paul Benedict <pb...@apache.org>.
Anjib,

It depends on how you configure your struts action. If you have
validate="true" on, then no -- failed validation will never make it to your
action. If you want to call validate() yourself in execute() and perform
additional validation, go for it.

Paul

On Tue, Dec 28, 2010 at 12:20 PM, Anjib Mulepati <an...@hotmail.com>wrote:

> Struts 1.3.8
>
> Can I use validate.xml and validate() method at same time
>
> a) for same field in both place and
> b) different disjunctive fields.
>
> Anjib
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>