This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

about null value in struts 2

asif rafique

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

Joined: Aug 03, 2008
Posts: 9405

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
I agree. Here's the link:
subject: about null value in struts 2
It's not a secret anymore!