You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John De Lello <Jo...@DelWare.com> on 2006/09/12 13:13:36 UTC

Validation and Form Collections

Hello Everyone,

I have a question regarding validation.

I have JSP that uses the Html:Options tag to populate a DDLB. The action
class creates the collection and puts it in the Form. All works fine until
the form validation fails. When I come back from the form validation, I am
getting a "Bean define cannot assign to a null value" error. 

I know this is because the action class is never reached if validation
fails, so I'm wondering how I can preserve the collection in the form in
that case. Do I need to re-populate the collection in the validate method if
a failure occurs? I was trying to keep all that logic in the action class
only. I can't put the collection in Session because for other reasons that I
don't control.

Any help or suggestions would be appreciated.
Thank you
John



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


Re: Validation and Form Collections

Posted by Laurie Harper <la...@holoweb.net>.
John De Lello wrote:
> I have JSP that uses the Html:Options tag to populate a DDLB. The action

Populate a what? :-)

> class creates the collection and puts it in the Form. All works fine until
> the form validation fails. When I come back from the form validation, I am
> getting a "Bean define cannot assign to a null value" error. 
> 
> I know this is because the action class is never reached if validation
> fails, so I'm wondering how I can preserve the collection in the form in
> that case. Do I need to re-populate the collection in the validate method if
> a failure occurs? I was trying to keep all that logic in the action class
> only. I can't put the collection in Session because for other reasons that I
> don't control.

It sounds like the 'input' attribute on your action mapping is pointing 
directly at the JSP that generates the form. If you need to pre-populate 
data before rendering the JSP, you should have the 'input' attribute 
point to the appropriate action mapping instead. If validation fails, 
Struts will then invoke the action which can initialize your collection 
before forwarding to the JSP.

Without seeing what your existing code and configuration looks like it's 
hard to be more specific than that, so if that doesn't give you enough 
to solve the problem, try posting the relevant sections of your 
struts-config.xml and action class with a description of what you tried.

L.


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


RE: Validation and Form Collections

Posted by Raghuveer <ra...@infotechsw.com>.
put the actionform scope in session in your <action mapping in
struts-config.xml

-----Original Message-----
From: John De Lello [mailto:JohnD@DelWare.com]
Sent: Tuesday, September 12, 2006 4:44 PM
To: user@struts.apache.org
Subject: Validation and Form Collections


Hello Everyone,

I have a question regarding validation.

I have JSP that uses the Html:Options tag to populate a DDLB. The action
class creates the collection and puts it in the Form. All works fine until
the form validation fails. When I come back from the form validation, I am
getting a "Bean define cannot assign to a null value" error.

I know this is because the action class is never reached if validation
fails, so I'm wondering how I can preserve the collection in the form in
that case. Do I need to re-populate the collection in the validate method if
a failure occurs? I was trying to keep all that logic in the action class
only. I can't put the collection in Session because for other reasons that I
don't control.

Any help or suggestions would be appreciated.
Thank you
John




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