You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Newton <ne...@yahoo.com> on 2007/05/03 16:05:28 UTC

[S1] Form validation woes...

Hey,

Working on an S1 app at the moment (shaddup, all a'
ya').

Things are set up a bit weird compared to what I'm
used to; in this case there's an action that uses an
ActionForm that isn't declared in struts-config, and
that ActionForm contains nested ActionForms.

I need to do some validaton on one of the nested
ActionForms and would prefer to put it in
validation.xml, but since neither the parent nor child
forms are declared in struts-config I'm not sure I can
do this.

My naive implementation (define the sub-form
validation in validation.xml and call
subForm.validate(mapping, request) throws an NPE from
inside ValidatorForm.validate().

I've never really even thought of doing anything this
way so I'm unfamiliar with how struts-config and
validation.xml interact (or if they do). All the forms
seem to be instantiated by hand etc. so... I'm afraid
I have to do the validation by hand (which would suck,
because there's a wad of intRanges and validwhens and
the version of validator they're using doesn't seem to
have all the standalone validation routines).

I'm just wondering if what I want to do is (reasonable
and) possible.

Thanks,
Dave


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: [S1] Form validation woes...

Posted by Dave Newton <ne...@yahoo.com>.
--- Niall Pemberton <ni...@gmail.com> wrote:
> [...] except some guys made me go out drinking beer 
> till late last night here at ApacheCon!!!!

Those darn guys! ;)

d.



 
____________________________________________________________________________________
We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

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


Re: [S1] Form validation woes...

Posted by Niall Pemberton <ni...@gmail.com>.
On 5/4/07, Dave Newton <ne...@yahoo.com> wrote:
> Hey,
>
> Just out of curiosity, when did you post this? I've
> had some weird list timing things happening lately,
> 'cuz I posted that I had solved this yesterday (with
> the getValidationKey solution :)

Yeah I was reading thru' in order and didn't see you had already
solved it I only posted a few minutes ago. I might have replied
earlier except some guys made me go out drinking beer till late last
night here at ApacheCon!!!!

Niall


> Thanks,
> d.
>
> --- Niall Pemberton <ni...@gmail.com> wrote:
>
> > On 5/3/07, Dave Newton <ne...@yahoo.com>
> > wrote:
> > > Hey,
> > >
> > > Working on an S1 app at the moment (shaddup, all
> > a'
> > > ya').
> > >
> > > Things are set up a bit weird compared to what I'm
> > > used to; in this case there's an action that uses
> > an
> > > ActionForm that isn't declared in struts-config,
> > and
> > > that ActionForm contains nested ActionForms.
> > >
> > > I need to do some validaton on one of the nested
> > > ActionForms and would prefer to put it in
> > > validation.xml, but since neither the parent nor
> > child
> > > forms are declared in struts-config I'm not sure I
> > can
> > > do this.
> >
> > AFAIK the only link to the struts-config.xml is the
> > ActionMapping
> > passed to the validate method - which is used in the
> > getValidationKey() method to determine the "form
> > name" defined in your
> > validation.xml
> >
> > > My naive implementation (define the sub-form
> > > validation in validation.xml and call
> > > subForm.validate(mapping, request) throws an NPE
> > from
> > > inside ValidatorForm.validate().
> >
> > Which line is it failing on (and which Struts
> > version)? My guess is
> > if, as you say, no forms are defined in the
> > struts-config.xml then the
> > "attribute" value of the ActionMapping is null -
> > probably causing your
> > NPE. So either override the getValidationKey()
> > method in your action
> > form - or create your own dummy ActionMapping with
> > the "attribute" set
> > to the name of the form defined in your
> > validator.xml for the
> > validations you want executed.
> >
> > Niall
> >
> > > I've never really even thought of doing anything
> > this
> > > way so I'm unfamiliar with how struts-config and
> > > validation.xml interact (or if they do).
> > >
> > > All the forms
> > > seem to be instantiated by hand etc. so... I'm
> > afraid
> > > I have to do the validation by hand (which would
> > suck,
> > > because there's a wad of intRanges and validwhens
> > and
> > > the version of validator they're using doesn't
> > seem to
> > > have all the standalone validation routines).
> > >
> > > I'm just wondering if what I want to do is
> > (reasonable
> > > and) possible.
> > >
> > - make sure whatever action mapping has the
> > appropriate value
> >
> > > Thanks,
> > > Dave
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > > http://mail.yahoo.com
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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: [S1] Form validation woes...

Posted by Dave Newton <ne...@yahoo.com>.
Hey,

Just out of curiosity, when did you post this? I've
had some weird list timing things happening lately,
'cuz I posted that I had solved this yesterday (with
the getValidationKey solution :)

Thanks,
d.

--- Niall Pemberton <ni...@gmail.com> wrote:

> On 5/3/07, Dave Newton <ne...@yahoo.com>
> wrote:
> > Hey,
> >
> > Working on an S1 app at the moment (shaddup, all
> a'
> > ya').
> >
> > Things are set up a bit weird compared to what I'm
> > used to; in this case there's an action that uses
> an
> > ActionForm that isn't declared in struts-config,
> and
> > that ActionForm contains nested ActionForms.
> >
> > I need to do some validaton on one of the nested
> > ActionForms and would prefer to put it in
> > validation.xml, but since neither the parent nor
> child
> > forms are declared in struts-config I'm not sure I
> can
> > do this.
> 
> AFAIK the only link to the struts-config.xml is the
> ActionMapping
> passed to the validate method - which is used in the
> getValidationKey() method to determine the "form
> name" defined in your
> validation.xml
> 
> > My naive implementation (define the sub-form
> > validation in validation.xml and call
> > subForm.validate(mapping, request) throws an NPE
> from
> > inside ValidatorForm.validate().
> 
> Which line is it failing on (and which Struts
> version)? My guess is
> if, as you say, no forms are defined in the
> struts-config.xml then the
> "attribute" value of the ActionMapping is null -
> probably causing your
> NPE. So either override the getValidationKey()
> method in your action
> form - or create your own dummy ActionMapping with
> the "attribute" set
> to the name of the form defined in your
> validator.xml for the
> validations you want executed.
> 
> Niall
> 
> > I've never really even thought of doing anything
> this
> > way so I'm unfamiliar with how struts-config and
> > validation.xml interact (or if they do).
> >
> > All the forms
> > seem to be instantiated by hand etc. so... I'm
> afraid
> > I have to do the validation by hand (which would
> suck,
> > because there's a wad of intRanges and validwhens
> and
> > the version of validator they're using doesn't
> seem to
> > have all the standalone validation routines).
> >
> > I'm just wondering if what I want to do is
> (reasonable
> > and) possible.
> >
> - make sure whatever action mapping has the
> appropriate value
> 
> > Thanks,
> > Dave
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > 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
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: [S1] Form validation woes...

Posted by Niall Pemberton <ni...@gmail.com>.
On 5/3/07, Dave Newton <ne...@yahoo.com> wrote:
> Hey,
>
> Working on an S1 app at the moment (shaddup, all a'
> ya').
>
> Things are set up a bit weird compared to what I'm
> used to; in this case there's an action that uses an
> ActionForm that isn't declared in struts-config, and
> that ActionForm contains nested ActionForms.
>
> I need to do some validaton on one of the nested
> ActionForms and would prefer to put it in
> validation.xml, but since neither the parent nor child
> forms are declared in struts-config I'm not sure I can
> do this.

AFAIK the only link to the struts-config.xml is the ActionMapping
passed to the validate method - which is used in the
getValidationKey() method to determine the "form name" defined in your
validation.xml

> My naive implementation (define the sub-form
> validation in validation.xml and call
> subForm.validate(mapping, request) throws an NPE from
> inside ValidatorForm.validate().

Which line is it failing on (and which Struts version)? My guess is
if, as you say, no forms are defined in the struts-config.xml then the
"attribute" value of the ActionMapping is null - probably causing your
NPE. So either override the getValidationKey() method in your action
form - or create your own dummy ActionMapping with the "attribute" set
to the name of the form defined in your validator.xml for the
validations you want executed.

Niall

> I've never really even thought of doing anything this
> way so I'm unfamiliar with how struts-config and
> validation.xml interact (or if they do).
>
> All the forms
> seem to be instantiated by hand etc. so... I'm afraid
> I have to do the validation by hand (which would suck,
> because there's a wad of intRanges and validwhens and
> the version of validator they're using doesn't seem to
> have all the standalone validation routines).
>
> I'm just wondering if what I want to do is (reasonable
> and) possible.
>
- make sure whatever action mapping has the appropriate value

> Thanks,
> Dave
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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: [S1] Form validation woes... (SOLVED)

Posted by Niall Pemberton <ni...@gmail.com>.
Doh! Just replied to the other thread :)

Niall

On 5/3/07, Dave Newton <ne...@yahoo.com> wrote:
> Followup:
>
> Overriding getValidationKey(...) fixed it.
>
> --- Dave Newton <ne...@yahoo.com> wrote:
>
> > Hey,
> >
> > Working on an S1 app at the moment (shaddup, all a'
> > ya').
> >
> > Things are set up a bit weird compared to what I'm
> > used to; in this case there's an action that uses an
> > ActionForm that isn't declared in struts-config, and
> > that ActionForm contains nested ActionForms.
> >
> > I need to do some validaton on one of the nested
> > ActionForms and would prefer to put it in
> > validation.xml, but since neither the parent nor
> > child
> > forms are declared in struts-config I'm not sure I
> > can
> > do this.
> >
> > My naive implementation (define the sub-form
> > validation in validation.xml and call
> > subForm.validate(mapping, request) throws an NPE
> > from
> > inside ValidatorForm.validate().
> >
> > I've never really even thought of doing anything
> > this
> > way so I'm unfamiliar with how struts-config and
> > validation.xml interact (or if they do). All the
> > forms
> > seem to be instantiated by hand etc. so... I'm
> > afraid
> > I have to do the validation by hand (which would
> > suck,
> > because there's a wad of intRanges and validwhens
> > and
> > the version of validator they're using doesn't seem
> > to
> > have all the standalone validation routines).
> >
> > I'm just wondering if what I want to do is
> > (reasonable
> > and) possible.
> >
> > Thanks,
> > Dave
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > http://mail.yahoo.com
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> > user-help@struts.apache.org
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> 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: [S1] Form validation woes... (SOLVED)

Posted by Dave Newton <ne...@yahoo.com>.
Followup:

Overriding getValidationKey(...) fixed it.

--- Dave Newton <ne...@yahoo.com> wrote:

> Hey,
> 
> Working on an S1 app at the moment (shaddup, all a'
> ya').
> 
> Things are set up a bit weird compared to what I'm
> used to; in this case there's an action that uses an
> ActionForm that isn't declared in struts-config, and
> that ActionForm contains nested ActionForms.
> 
> I need to do some validaton on one of the nested
> ActionForms and would prefer to put it in
> validation.xml, but since neither the parent nor
> child
> forms are declared in struts-config I'm not sure I
> can
> do this.
> 
> My naive implementation (define the sub-form
> validation in validation.xml and call
> subForm.validate(mapping, request) throws an NPE
> from
> inside ValidatorForm.validate().
> 
> I've never really even thought of doing anything
> this
> way so I'm unfamiliar with how struts-config and
> validation.xml interact (or if they do). All the
> forms
> seem to be instantiated by hand etc. so... I'm
> afraid
> I have to do the validation by hand (which would
> suck,
> because there's a wad of intRanges and validwhens
> and
> the version of validator they're using doesn't seem
> to
> have all the standalone validation routines).
> 
> I'm just wondering if what I want to do is
> (reasonable
> and) possible.
> 
> Thanks,
> Dave
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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