Hi all,
even after scanning the doco, examples, source code and previous posts I
still can't get validation to happen for an indexed field in my Struts
(1.2.4) application working. I would really appreciate some help crafting
the appropriate validation definition.
My form is defined as
<form name="/cart/updateItems">
<field property="quantity" indexedListProperty="quantityArray"
depends="required, integer">
</field>
</form>
A 'quantityArray' parameter is supplied with the Request and is an array of
Integer like Strings.
The Struts ActionForm has the following methods:
public Integer getQuantity(int index);
/*
* NB it is not expected that this method will ever be called,
* but I think it is needed so that the commons-validator recognises
'quantity' as a property.
*/
public void setQuantity(int index, Integer quantity);
public Integer[] getQuantityArray();
public void setQuantityArray(Integer[] quantity);
But this combination causes the following Exception to be thrown during
validation:
24734 ERROR org.apache.commons.validator.util.ValidatorUtils - Unknown
property 'quantity'
java.lang.NoSuchMethodException: Unknown property 'quantity'
at
org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.j
ava:1175)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
ava:772)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:80
1)
at
org.apache.commons.validator.util.ValidatorUtils.getValueAsString(ValidatorU
tils.java:105)
at
org.apache.struts.validator.FieldChecks.validateRequired(FieldChecks.java:87
)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.validator.ValidatorAction.executeValidationMethod(Validat
orAction.java:567)
at
org.apache.commons.validator.Field.validateForRule(Field.java:811)
at org.apache.commons.validator.Field.validate(Field.java:890)
at org.apache.commons.validator.Form.validate(Form.java:174)
at
org.apache.commons.validator.Validator.validate(Validator.java:367)
at
org.apache.struts.validator.ValidatorForm.validate(ValidatorForm.java:112)
I tried dozens of different combos with no luck.
What do I need to do to validate a collection of properties of unknown size
using the commons-validator?
NB crossposting to both commons and struts lists.
William
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]