I have a problem with struts tags and I can not fix it!!.
In fact, I am using in my jsp nested tags for:
1- selecting items from a list of objects (and by the way, those lists
are themselves repeated several times in another nested:iterate tag )
2- display itereted input boxes with another nested:iterate tag. This
input boxs are filled from a list of objects (listAttValue)and when
the user enter a new value and click on submit, those values are
inserted in the bean after executing the validate method in the Action
form.
Here is my code:
<nested:iterate property="<%= Constants.LIST_NEW_CATEGORY_ITEMS %>"
>
<tr>
<td>
<html:select name="<%=Constants.CATEGORY_ITEM %>"
property="concatAttValues" indexed="true"
onchange="extract(this.name, this.value)">
<html:options
collection="<%=Constants.LIST_CATEGORY_ITEMS %>" property="itemId"
labelProperty="concatAttValues"/>
</html:select>
</td>
<td>
<html:hidden name="<%= Constants.LIST_NEW_CATEGORY_ITEMS
%>" property="itemId" indexed="true"/>
<nested:iterate property="listAttValue" >
<nested:write property="attValueId"/>
<nested:text property="attValue"/>
</nested:iterate>
</td>
</tr>
</nested:iterate>
So far everything is correct. I just have to code my validate method
and everything is setted by itself
I was very happy (in the beginning) with the result and the
felxibility the nested tags give. But the a problem came up
The Big Problem is the following:
When I select an Item from one of my select lists, I want a javascript
fonction(extract()), extract substrings from the item selected and
then put those substrings in the input text boxes (which contents
should be affected later, during the submit to the object
listAttributs, just like if the user input them by hand)
So the idea is to affect those substrings, in the extract function, to
the name of the input fields.
But as you know, when we use nested tags, ALL the input fields name in
the Html result are indexed
example:
listNewCategoryItems[0].listAttValue[1].attValue
And if I use this syntax in my extract method, a javaScript error
occurs saying: Object Expected
I think that the javascript doesn't accept the indexed syntax above
because As soon as I remove this instruction, the error disapears.
So what should I do to code my javascript method and have my
fonctionnalty and fix my problem????
I have been struggling with this problem for many days and I haven't
find the solution yet
Please help me!!!!
Thank you so much
Lou