Hi guys,

I just ran into a strange situation where binding empty values on indexed properties.

I have some properties on my bean:
someObject.someChildren[0].field1
someObject.someChildren[0].field2

where someChildren is a List.


None of them (field1 and field2) are mandatory so I want them to be set to empty/null/whatever when there is no input in a corresponding:

        <s:text name="someObject.someChildren[0].field1"/>
        <s:text name="someObject.someChildren[0].field2"/>


This doesn't work at all, but this seems to work great:

        <s:text name="someObject.someChildren.0.field1"/>
        <s:text name="someObject.someChildren.0.field2"/>



After cracking my head for a couple of hours, I realized that the problem is here (DefaultActionBeanPropertyBinder.java):

protected void validateRequiredFields(Map<ParameterName, String[]> parameters, ActionBean bean, ValidationErrors errors) {

       
//something........

        // Now the easy work is done, figure out which rows of indexed props had values submitted
        // and what to flag up as failing required field validation
        if (indexedParams.size() > 0) {

           
//something........

            for (Row row : rows.values()) {
                if (row.hasNonEmptyValues()) {
                       //something........
                }
                else {
                    // If the row is full of empty data, get rid of it all to
                    // prevent problems in downstream validation
                    //MY COMMENT: WHY????
                    for (ParameterName name : row.keySet()) {
                        parameters.remove(name);
                    }
                }
            }
        }
    }

Any clue why this is really necessary?

Thanks in advance,
Cosmin
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to