Dear all, I am building web application using Struts. I want to copy the value of a form into a value object using Bean Utils. Does BeanUtils.copyProperties method include trimming process for every value of the form? Or do I have to do trimming process manually before I use BeanUtils.copyProperties method?
thanks daniel
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
posted
0
you must create trim() process before call PropertyUtils.copyProperties(). because this method not have trim() process.
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Paul Strachan
Greenhorn
Joined: Oct 24, 2004
Posts: 10
posted
0
you could trim() in your value object setter method. eg.
you can use StringUtils.trim() to reduce your code lines.
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
posted
0
Originally posted by Siripa Siangklom: you can use StringUtils.trim() to reduce your code lines.
yep, its good point.
StringUtils.trim( ) delegates to the trim( ) function on String and gracefully handles null. When you pass a null to StringUtils.trim( ), it returns a null.
And you can use trimming to NULL of StringUtils ::