On 5/26/06, Jean-Marie Pitre <[EMAIL PROTECTED]> wrote:
Hi,

I am developing an application with struts and custom JSP tags.

In my custom tag I would like to retrieve the getIndexValue() when I use it 
inside an iterate (in order to change its name like xxx[1] ...).

Have you got any idea?

Struts's BaseHandlerTag (see http://tinyurl.com/lowx9) provides this
for the html taglib when they are embedded either in a struts
IterateTag or in a JSTL loop (see the getIndexValue() method).

If you just want to cater for the struts IterateTag then you can do
the following:

  protected int getIndexValue()
       throws JspException {
       // look for outer iterate tag
       IterateTag iterateTag =
           (IterateTag) findAncestorWithClass(this, IterateTag.class);

       if (iterateTag != null) {
           return iterateTag.getIndex();
       } else {
           return -1;
       }
  }

Niall

Thanks,

Best regards,

Jean-Marie.

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

Reply via email to