struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@lexmark.com
Subject Re: Index within iterate tags
Date Tue, 14 Aug 2001 16:46:06 GMT


Hi Nicola,

Believe there is a way to extract it already (but never used it)...but If you
only need the index for javascript, can't you obtain it from the name of your
indexed field ie pass the field in as a param to your function?

I do this with a button defined with
                   <html:button property="y" value="reset" indexed="true"
onclick="setParamDefault(this)"/>

and my function is

function setParamDefault(button)
{
    var myName = button.name;
   var start = myName.indexOf("[") + 1;
   var length = myName.indexOf("]") - start;
   var index = myName.substr(start, length);

   document.ParametersForm["parameter[" + index + "].value"].value =
document.ParametersForm["parameter[" + index + "].defaultValue"].value

}

Cheers,

Dave






Nicola Taylor <nicola.taylor%levelseas.com@interlock.lexmark.com> on 08/14/2001
12:00:21 PM

Please respond to struts-user%jakarta.apache.org@interlock.lexmark.com

To:   "Struts-User (E-mail)"
      <struts-user%jakarta.apache.org@interlock.lexmark.com>
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  Index within iterate tags



Hi,

were using the indexed properties tags and it'd be useful to know the
current index in the jsp (to do some javascript stuff).  Is there any
standard way to access the current index in the iterator?

1) write a custom tag to return:
IterateTag iterateTag = (IterateTag) findAncestorWithClass(this,
IterateTag.class);
iterateTag.getIndex();

2) have a counter variable that we increment within the iterate loop.

Cheers


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************







Mime
View raw message