Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: Release 1.4.1
-
Fix Version/s: None
-
Component/s: Validation
-
Labels:None
-
Environment:Windows / Tomcat 5.5
Description
I've been working on a javascript-enabled form that allows you to dynamically add and remove 'rows' in a table, represented by TreeMaps of beans stripes-side:
public TreeMap<Long, ChannelDataBean> getChannels() { return this.channels; }
public void setChannels(TreeMap<Long, ChannelDataBean> channels) { this.channels = channels; }
@ValidateNestedProperties
({
@Validate(field="name", required=true, minlength=3, maxlength=50),
@Validate(field="incomingUsername", required=true, minlength=3, maxlength=50),
@Validate(field="outgoingUsername", required=true, minlength=3, maxlength=50),
@Validate(field="incomingPassword", required=true, minlength=3, maxlength=50),
@Validate(field="outgoingPassword", required=true, minlength=3, maxlength=50)
})
private TreeMap<Long, ChannelDataBean> channels;
and their appropriate inputs, generated by reflection, page side.
It works great – unless you try and submit a form with no elements at all. In this case, Stripes reports validation errors for every single bean property described in the corresponding nested @Validate annotation.
Is there a work-around for this, aside from implementing a ValidationErrorHandler (I kind of want the solution to be totally portable and generic, which it is currently), or is this a bug.
Cheers
Si
PS: I love stripes, it's seriously excellent. Cheers for the terrific framework.
I'd say this is a bug. The whole idea is that for indexed properties only those indexes that have some values get validated. The reason this is happening is because the detection of when a property is indexed is based on there being indexed style keys in the request. I think all I'd need to do is alter this to actually inspect the bean and see if a property is indexed instead.