Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validate method not completing

 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've checked if String's length is less than 0, you'll have to check if its == 0...
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ..

Here you are getting a length 0.

It must be ==0
0r <=0


Thanks.
 
MaheshS Kumbhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its working fine now Raza
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic