[ 
http://www.stripesframework.org/jira/browse/STS-460?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12851#comment-12851
 ] 

Tim Burt commented on STS-460:
------------------------------

I just wanted to note another aspect of this that is biting me now, and I 
haven't figured out a workaround yet.  If the string property is associated 
with a map (i.e. form.map.test) and is the only form value being sent (in our 
environment, we only send changed form values), then the map is never 
instantiated so I cannot just call BeanUtils/PropertyUtils to set 
"form.map.test".  

Personally, I (still) believe that this behavior should be optional, or at 
least easy to override.  As it is, I lose the fact that the user changed a form 
field value from some non-empty string to the empty string -- I don't care 
whether the value is represented as the empty string or null, but I do need to 
know that they modified the value.  As it stands now, the action class has no 
indication that the form field was changed.

> Empty form text fields give null String values
> ----------------------------------------------
>
>                 Key: STS-460
>                 URL: http://www.stripesframework.org/jira/browse/STS-460
>             Project: Stripes
>          Issue Type: Improvement
>          Components: ActionBean Dispatching
>    Affects Versions: Release 1.4.3
>         Environment: Windows/Linux, Tomcat 5.5.25
>            Reporter: Phil Sladen
>            Assignee: Tim Fennell
>
> I can understand that empty form fields give rise to empty objects when there 
> is a converter involved and invalid input, but it seems a bit OTT to also 
> treat Strings the same way. Although String is not a native type, it is 
> treated as such in some respects in the language, and I think Stripes should 
> do the same by default. Otherwise, code is going to be littered with checks 
> for null or be forced to use something like StringUtils. I would however 
> expect the String to be left unaltered, and possibly null, if the 
> corresponding parameter is not provided in the request. I could then choose 
> whether such extra checks are warranted for Strings as well as other objects.
> Instead, I found the most convenient way around the issue was to provide my 
> own PropertyBinder:
> public class MyPropertyBinder extends DefaultActionBeanPropertyBinder {
>         protected void bindNullValue(ActionBean bean, String property, Class 
> type)
>                         throws ExpressionException {
>                 if (type == String.class) {
>                         BeanUtil.setPropertyValue(property, bean, new 
> String());
>                 }
>                 else {
>                         super.bindNullValue(bean, property, type);
>                 }
>         }
> }
> All credit due to Stripes extensibility, but I don't think I should have to 
> do this.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to