wood burning stoves 2.0*
The moose likes Struts and the fly likes struts validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts validator " Watch "struts validator " New topic
Author

struts validator

Nitin Raodeo
Greenhorn

Joined: Jul 27, 2002
Posts: 21
I am using struts validator for some feilds on my jsp.
I have a action form in which there is a collection (array) as the member variable.
I want to make one of member variable of the array class as mandatory.
I get a null pointer excetion if the collection (array) is null.
I want to stop the validation when the data is null(when the screen is loaded for the first time)
Please help
Nitin


1) SCJP 1.4<br />2) SCBCD (EJB 2.0)<br />3) IBM WebSphere Portal<br />4) WSAD (exam 287)
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4447
    
    5

Initialize your field to a zero-length array, do the same thing in the form's reset() method.
To handle the first-time display, I usually check if a specific action came in with the request (I map all my submit buttons to a property called 'action') so my check in validate() is usually:
if (action == null) return null;
If I have many conditions to check, I'll pull those conditions out to a query method so I can write something like
if (skipValidate()) return null;


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts validator
 
Similar Threads
Using DispatchAction ,error whe nusing request scope
How can we determine whether an object's reference variable is null or not?
garbage collection
error
struts integer validator