You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sun Shine <sp...@yahoo.com> on 2005/12/05 00:19:41 UTC

help using validate inside ActionForm

Hi all,
In my application, I'm using one ActionForm Bean for
several pages. How do I properly use validate method
when user goes from one page to another? It's a
collection of data, so, on page 1, I need to validate
X fields, on page 2, validate Y fields, etc.

Is there an easy way to tell what page I am coming
from?

Any help is appreciated!

Thanks,
Penny


		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

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


Re: help using validate inside ActionForm

Posted by Laurie Harper <la...@holoweb.net>.
+1

In terms of this particular requirement, what the validator framework 
does is provide the concept of 'pages' and page-specific validatons 
(think of a wizard, where each screen in the wizard is a 'page' and each 
validation rule is marked as being applicable to a specific page).

Even if you don't want to switch to using the validator framework, you 
may want to implement the same concept in your own validation logic.

L.

Raghu Kanchustambham wrote:
> While the "if" loops in the validate function of the form will work... i
> somehow think you are coupling the workflow with the validation rules. Why
> dont you look at the validation framework so that you "externalize" your
> validation logic into xml files?
> 
> You can perform validation on a per form basis and also on a per action
> basis in the validator framework. The second case may be useful to you.
> 
> ~raghu
> 
> 
> On 12/5/05, Sun Shine <sp...@yahoo.com> wrote:
>> Thank you!
>>
>> --- David Evans <ds...@berndtgroup.net> wrote:
>>
>>> A few ideas that may get you started:
>>>
>>> you can use different names for the submit or image
>>> tags that you are
>>> using to submit the forms, and set up an if, else if
>>> structure in your
>>> validate method to see which page has submitted to
>>> the actionForm based
>>> on the parameters input. or use hidden tags to do
>>> the same thing. or use
>>> the HttpServletRequest's getPathInfo().
>>>
>>> dave
>>>
>>> On Sun, 2005-12-04 at 15:19 -0800, Sun Shine wrote:
>>>> Hi all,
>>>> In my application, I'm using one ActionForm Bean
>>> for
>>>> several pages. How do I properly use validate
>>> method
>>>> when user goes from one page to another? It's a
>>>> collection of data, so, on page 1, I need to
>>> validate
>>>> X fields, on page 2, validate Y fields, etc.
>>>>
>>>> Is there an easy way to tell what page I am coming
>>>> from?
>>>>
>>>> Any help is appreciated!
>>>>
>>>> Thanks,
>>>> Penny
>>>>
>>>>
>>>>
>>>> __________________________________
>>>> Start your day with Yahoo! - Make it your home
>>> page!
>>>> http://www.yahoo.com/r/hs
>>>>
>>>>
>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>
>>
>>
>> __________________________________
>> Start your day with Yahoo! - Make it your home page!
>> http://www.yahoo.com/r/hs
>>
>> ---------------------------------------------------------------------
>> 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: help using validate inside ActionForm

Posted by Raghu Kanchustambham <kr...@gmail.com>.
While the "if" loops in the validate function of the form will work... i
somehow think you are coupling the workflow with the validation rules. Why
dont you look at the validation framework so that you "externalize" your
validation logic into xml files?

You can perform validation on a per form basis and also on a per action
basis in the validator framework. The second case may be useful to you.

~raghu


On 12/5/05, Sun Shine <sp...@yahoo.com> wrote:
>
> Thank you!
>
> --- David Evans <ds...@berndtgroup.net> wrote:
>
> > A few ideas that may get you started:
> >
> > you can use different names for the submit or image
> > tags that you are
> > using to submit the forms, and set up an if, else if
> > structure in your
> > validate method to see which page has submitted to
> > the actionForm based
> > on the parameters input. or use hidden tags to do
> > the same thing. or use
> > the HttpServletRequest's getPathInfo().
> >
> > dave
> >
> > On Sun, 2005-12-04 at 15:19 -0800, Sun Shine wrote:
> > > Hi all,
> > > In my application, I'm using one ActionForm Bean
> > for
> > > several pages. How do I properly use validate
> > method
> > > when user goes from one page to another? It's a
> > > collection of data, so, on page 1, I need to
> > validate
> > > X fields, on page 2, validate Y fields, etc.
> > >
> > > Is there an easy way to tell what page I am coming
> > > from?
> > >
> > > Any help is appreciated!
> > >
> > > Thanks,
> > > Penny
> > >
> > >
> > >
> > > __________________________________
> > > Start your day with Yahoo! - Make it your home
> > page!
> > > http://www.yahoo.com/r/hs
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
>
>
> __________________________________
> Start your day with Yahoo! - Make it your home page!
> http://www.yahoo.com/r/hs
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: help using validate inside ActionForm

Posted by Sun Shine <sp...@yahoo.com>.
Thank you!

--- David Evans <ds...@berndtgroup.net> wrote:

> A few ideas that may get you started:
> 
> you can use different names for the submit or image
> tags that you are
> using to submit the forms, and set up an if, else if
> structure in your
> validate method to see which page has submitted to
> the actionForm based
> on the parameters input. or use hidden tags to do
> the same thing. or use
> the HttpServletRequest's getPathInfo().
> 
> dave
> 
> On Sun, 2005-12-04 at 15:19 -0800, Sun Shine wrote:
> > Hi all,
> > In my application, I'm using one ActionForm Bean
> for
> > several pages. How do I properly use validate
> method
> > when user goes from one page to another? It's a
> > collection of data, so, on page 1, I need to
> validate
> > X fields, on page 2, validate Y fields, etc.
> > 
> > Is there an easy way to tell what page I am coming
> > from?
> > 
> > Any help is appreciated!
> > 
> > Thanks,
> > Penny
> > 
> > 
> > 		
> > __________________________________ 
> > Start your day with Yahoo! - Make it your home
> page! 
> > http://www.yahoo.com/r/hs
> > 
> >
>
---------------------------------------------------------------------
> > 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
> 
> 



		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs

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


Re: help using validate inside ActionForm

Posted by David Evans <ds...@berndtgroup.net>.
A few ideas that may get you started:

you can use different names for the submit or image tags that you are
using to submit the forms, and set up an if, else if structure in your
validate method to see which page has submitted to the actionForm based
on the parameters input. or use hidden tags to do the same thing. or use
the HttpServletRequest's getPathInfo().

dave

On Sun, 2005-12-04 at 15:19 -0800, Sun Shine wrote:
> Hi all,
> In my application, I'm using one ActionForm Bean for
> several pages. How do I properly use validate method
> when user goes from one page to another? It's a
> collection of data, so, on page 1, I need to validate
> X fields, on page 2, validate Y fields, etc.
> 
> Is there an easy way to tell what page I am coming
> from?
> 
> Any help is appreciated!
> 
> Thanks,
> Penny
> 
> 
> 		
> __________________________________ 
> Start your day with Yahoo! - Make it your home page! 
> http://www.yahoo.com/r/hs
> 
> ---------------------------------------------------------------------
> 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