Should the tag be:
<html-el:text property="testData[${testForm.num}].data" maxlength="16"
size="16"/>
-----Original Message-----
From: Karl [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 9:58 PM
To: Struts Users Mailing List
Subject: Using a form property as an index into another property
Is it possible to use one form property as an index into another form
property?
I'm trying to do the following:
<html:form action="do_test.do" name="testForm"
type="com.somewhere.TestForm">
<html:text property="testData[num].data" maxlength="16" size="16"/>
<html:submit value="Set"/>
</html:form>
where TestForm has the following:
private Vector myCollection;
{
myCollection = new Vector();
myCollection.add(new TestData("1"));
myCollection.add(new TestData("two"));
myCollection.add(new TestData("III"));
}
public Collection getTestData() {
return myCollection;
}
public TestData getTestData(int index) {
return (TestData)myCollection.get(index);
}
private int num = 0;
public int getNum() {
return num;
}
public void setNum(String num) {
this.num = Integer.parseInt(num);
}
public void setNum(int num) {
this.num = num;
}
and TestData is defined as:
public final class TestData {
private String myData;
public TestData(String value) {
myData = value;
}
public String getData() {
return myData;
}
}
If I use a hardcoded index value, it works as expected:
<html:text property="testData[0].data" maxlength="16" size="16"/>
But if I try to use a form property as an index:
<html:text property="testData[num].data" maxlength="16" size="16"/>
It fails:
org.apache.jasper.JasperException: Invalid indexed property 'testData[num]'
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]