[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    Re: [PATCH] nested iterates and the indexed attribute
From:       dhay () lexmark ! com
Date:       2001-10-31 20:59:57
[Download RAW message or body]

Hi Tom,

apologies - I didn't read your initial note thoroughly enough - I thought you
were submitting a patch to allow for nested iterates, not just fixing the
problem of using an outer iterate param in the inner iterate.  You can ignore my
comments for that case!

Have looked at your patch, and it will fail if name=null when the prepareIndex
method is called.  This is the case with some of the tags eg button, and submit
(and img and image changes which I am about to submit).

Could you add a check for this?

Cheers,

Dave





"Tom Klaasen (TeleRelay)" <tom.klaasen%telerelay.com@interlock.lexmark.com> on
10/31/2001 11:47:09 AM

Please respond to "Struts Developers List"
      <struts-dev%jakarta.apache.org@interlock.lexmark.com>

To:   "Struts Developers List"
      <struts-dev%jakarta.apache.org@interlock.lexmark.com>
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  [PATCH] nested iterates and the indexed attribute



In case the answer is positive ("yes, this is a bug and not expected
behaviour"), I hereby attach a patch to solve it.

Tested with the html:radio tag, and it should work for all tags that
extend BaseHandlerTag (which, I presume but did not check, will be all
tags that can be indexed)

Let me know what you think about it,

tomK


> -----Original Message-----
> From: Tom Klaasen (TeleRelay)
> Sent: woensdag 31 oktober 2001 17:09
> To: Struts Developers List
> Subject: nested iterates and the indexed attribute
>
>
> Hi all,
>
> I think I discovered a bug in struts (nightly build 20011018):
>
> when I use nested iterates, the indexed attribute is always
> referring to
> the innermost iterate index, not the one which name is specified.
>
> so when I do
>
> <logic:iterate id="beanprop" name="bean" property="props">
>    <logic:iterate id="beanpropinner" name="beanprop"
> property="inner">
>         <html:radio name="beanprop" property="someIndex"
> value="someValue" indexed="true"/>
>    </logic:iterate>
> </logic:iterate>
>
> I get something like
>
> <input type="radio" name="beanprop[0].someIndex" value="someValue">
> <input type="radio" name="beanprop[1].someIndex" value="someValue">
> <input type="radio" name="beanprop[2].someIndex" value="someValue">
> <input type="radio" name="beanprop[0].someIndex" value="someValue">
> <input type="radio" name="beanprop[1].someIndex" value="someValue">
> <input type="radio" name="beanprop[2].someIndex" value="someValue">
> <input type="radio" name="beanprop[3].someIndex" value="someValue">
> <input type="radio" name="beanprop[4].someIndex" value="someValue">
>
> instead of the expected
>
> <input type="radio" name="beanprop[0].someIndex" value="someValue">
> <input type="radio" name="beanprop[0].someIndex" value="someValue">
> <input type="radio" name="beanprop[0].someIndex" value="someValue">
> <input type="radio" name="beanprop[1].someIndex" value="someValue">
> <input type="radio" name="beanprop[1].someIndex" value="someValue">
> <input type="radio" name="beanprop[1].someIndex" value="someValue">
> <input type="radio" name="beanprop[1].someIndex" value="someValue">
> <input type="radio" name="beanprop[1].someIndex" value="someValue">
>
> (watch the indexes)
>
> (Of course, "someValue" would be replaced by something that
> is computed
> and makes more sense. This computation is omitted here for simplicity)
>
> Now, should I in fact consider this a bug and try to solve this, or do
> you think this is expected behaviour?
>
>
> thanks,
> tomK
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-dev-> unsubscribe@jakarta.apache.org>
> For
> additional commands,
> e-mail: <mailto:struts-dev-help@jakarta.apache.org>
>
>

["BaseHandlerTag.java.diff" (application/octet-stream)]

Index: BaseHandlerTag.java
===================================================================
RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java,v
retrieving revision 1.9
diff -u -r1.9 BaseHandlerTag.java
--- BaseHandlerTag.java	2001/09/17 19:59:30	1.9
+++ BaseHandlerTag.java	2001/10/31 16:33:46
@@ -474,6 +474,9 @@
         throws JspException {
         // look for outer iterate tag
         IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, IterateTag.class);
+		while (iterateTag!=null && !iterateTag.getId().equals(name)) {
+			iterateTag = (IterateTag)findAncestorWithClass(iterateTag, IterateTag.class);
+		}
         if (iterateTag == null) {
              // this tag should only be nested in iteratetag, if it's not, throw exception
              JspException e = new JspException(messages.getMessage("indexed.noEnclosingIterate"));



--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>







--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic