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

Phil Sladen commented on STS-460:
---------------------------------

Hi Tim,
The fundamental point wasn't missed, although maybe the issue could have been 
described more fully. The custom property binder specified earlier will give 
the results you desire. Configure where Stripes looks for extensions with:
                <init-param>
                        <param-name>Extension.Packages</param-name>
                        <param-value>{your 
package}.MyPropertyBinder</param-value>
                </init-param>
Put the property binder class in package {your package} and you're good to go.
If the property is null before property binding takes place and the request 
doesn't have the property, then the property will still be null after property 
binding. However, if the request has an empty string for the property then it 
will be empty (not null) after property binding.


> 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

        

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to