This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Validate method not completing 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 "Validate method not completing" Watch "Validate method not completing" New topic

Validate method not completing

MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188
I have following code, in which second if is not working in validate method.

In above code, even if I fail to enter name, second 'if' is not failing, its invoking execute method. Although 'if' clause for 'number' is working fine, means if I enter number less than 0, its addFieldError method is getting called.
What could be the problem with above code snippet?

I am slow but sure
Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

You've checked if String's length is less than 0, you'll have to check if its == 0...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Raza Mohd
Ranch Hand

Joined: Jan 20, 2010
Posts: 247

hi ..

Here you are getting a length 0.

It must be ==0
0r <=0


Good luck!!
A small leak can sink a Gigantic ship.>
MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188
Its working fine now Raza
It is sorta covered in the JavaRanch Style Guide.
subject: Validate method not completing
Similar Threads
Error while validating the input
Struts2 whats the need for extending ActionSupport class
validation problem.
Problem populating a newly created HashMap in a Struts2 Action
Struts2: Problem with form validation using validation xml