aspose file tools*
The moose likes Struts and the fly likes about null value in struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "about null value in struts 2" Watch "about null value in struts 2" New topic
Author

about null value in struts 2

asif rafique
Greenhorn

Joined: Mar 25, 2007
Posts: 8
Hi everyone

i am using struts 2 in my project every thing is fine .
when i submit a form struts setter injection call setter of all bean properties and set there values, any text field that is left bland by user on submit it is initialize by empty string What i want a null instead of empty string
any help to submit a null value instead of String will be appreciated
thanks in advance
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Asif this is the correct behavior. When the request doesn't contain a request parameter, then the value of a parameter is null. If the request parameter exists, and has no value, then it is equivalent to an empty string. I think to avoid this, you must use the requiredstring-validator or implement your own parameter interceptor but the former would be the correct way of doing this...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
jQuery in Action, 2nd edition
 
subject: about null value in struts 2