Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

bug with setProperty when form field is empty?  RSS feed

 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was modifying a JSP another developer had come up with and added some fields, and when the fields had nothing in them, it didn't set the respective fields in the bean to nothing (empty String). Instead, the bean just maintained what it had stored before.
Shouldn't it overwrite what's in the bean's field/property if nothing was inputted on the form? I finally noticed that the original developer had a comment in which he said that it doesn't clear properly when it's empty, and you have to check the request variables manually and if they were empty, then you have to explicitly set it to empty in the bean.
Is this an oversight/bug, or is there some reason that this makes sense?
Thanks...
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
^
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the horse's mouth:

If a request parameter has an empty or null value, the corresponding Bean property is not set. Likewise, if the Bean has a property that does not have a matching request parameter, the property value is not set.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!