The problem is an incompatiblity with javascript names and nested tags.

The nested tags create names like

        property.nestedproperty

When you go to use this in javascript you do


        document.forms["yourform"].property.nestedproperty.{method}.

Javascript blows up at this point.

You need to get a pointer to the form field either with 'this' or
searching through the form fields on an indexed basis till you find the
one you are interested in.

Here is my little javascript to find a field.  


// determine a field from it's name
function Struts_eval(fieldName, fieldCount) {
    var objWrk = null;
    if (fieldName == null)
        return objWrk;
    if (fieldCount == null)
        fieldCount = 1;

    // now try the rediculous eval
    var findCount;
    findCount = 0;
    var len;
    for ( var i = 0; i < document.forms.length; i++ ) {
        for (var j = 0; j < document.forms[i].elements.length; j++) {
            if (document.forms[i].elements[j].name == fieldName) {
                if (++findCount == fieldCount) {
                    objWrk = document.forms[i].elements[j];
                    return objWrk;
                }
            }
            len = document.forms[i].elements[j].name.indexOf(fieldName);
            if (len < 0)
                continue;
            if (len + fieldName.length ==
document.forms[i].elements[j].name.length) {
                if (++findCount == fieldCount) {
                    objWrk = document.forms[i].elements[j];
                    return objWrk;
                }
            }
        }
    }
    return objWrk;
}

Edgar

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Monday, November 25, 2002 12:33 PM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: Nested Iterate Tag and indexId problem


I am using the nested tags with Struts 1.02.

I want to be able to dynamically set a call to a javascript function.  I

want to pass in the row number to the function.

I currently have....


<nested:iterate property="asrTranList" 
type="abbott.ai.tcgm.entities.AsrTran" indexId="idx">
        <tr>
                <td class="maintCenter">
                        <nested:text property="actionCode" maxlength="1"

size="1" styleClass="maintWidth1"
onchange="makeEditDirty('hideOnEdit','showOnEdit','<bean:write
name="idx" 
scope="page" />');"
                                onkeyup="return autoTab(this, 1,
event);" 
/>
                </td>
        </tr>
</nested:iterate>

This does not work.


I have also tried

<nested:iterate property="asrTranList" 
type="abbott.ai.tcgm.entities.AsrTran" indexId="idx">
        <tr>
                <td class="maintCenter">
                        <nested:text property="actionCode" maxlength="1"

size="1" styleClass="maintWidth1"
onchange="makeEditDirty('hideOnEdit','showOnEdit','<%="idx"%>');"
                                onkeyup="return autoTab(this, 1,
event);" 
/>
                </td>
        </tr>
</nested:iterate>

It does not work either.

It is looking to me like a bug with the nested tags.  They sure have
been 
very useful.  I would hate to change all the code back at this point.

Why can I use a regular jsp <%=idx%> to get the value of the indexId
from 
the iterate tag?

Thanks.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to