this is probably a constantly discussed topic and I have surely found a load
of inromation concerning this,but it still did not solve my problem.
I have a web page which displays multiple records, each record representing
one person. I am using index to retrieve each record.
The person is represented by bean Person:
public class Person { . . private int monthlySalary;
public int getMonthlySalary() { return monthlySalary; } public void setMonthlySalary(int monthlySalary) { this.monthlySalary = monthlySalary; } . . }
I use this form for the action called:
public final class PersonalForm extends ValidatorForm{ . . private List persons;
public Person getPersons(int index) { return (Person)persons.get(index); } public void setPersons(int index, Person value) { persons.set(index, value); } . . }
and in the JSP, it looks like this:
<logic:iterate id="person" name="personalForm" property="persons" indexId="index"> . . <html:text name="personalForm" property='<%="persons["+index+"].monthlySalary"%>' styleClass="monthlySalary"/> . . </logic:iterate>
Everything works just fine. What doesn't work is the validation.
I have validation.xml looking like this:
<form name="personalForm"> <field property="monthlySalary" indexedListProperty="persons" depends="integer"> <arg0 key="errors.integer"/> </field> </form>
When the page is loaded, i get the following exception in Tomcat:
ERROR: in validateField java.lang.NoSuchMethodException: Unknown property 'monthlySalary' at org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(Property Utils.java:1175) at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(Property Utils.java:772) . .
Where am I making mistake?
Thanks for suggetions.
Radek -
I usually do this with Dyan Forms based on Arrays, so the information may not be exactly what you're looking for...but based on my experience, I would try the following changes:
- change the id field in your iterate to be id="persons"
- change your html:text to be: <html:text indexed="true" name="persons" property="monthlySalary" styleClass="monthlySalary" />
- you don't have the code/config for your action here, but make sure that it extends one of the validating action form types.
Matt
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]