You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steve Armstrong <sa...@truecontext.com> on 2002/05/24 07:01:46 UTC

nested:iterate and indexId problems

Hi,

I'm using Struts 1.0.2 with the NeXt package targeted for that particular
load.  I'm having a problem evaluating the page scope Integer bean that
should be created via the indexId attribute.

Inside an <html:form>, I have something like the following for handling odd
and even rows of a table differently:

<nested:iterate property="phoneNumbers" indexId="loop">
<bean:define id="mod2" value="<%= Integer.toString(loop.intValue() % 2)
%>"/>
<logic:equal name="mod2" value="0">
<!-- stuff for an even row goes here -->
</logic:equal>
<logic:notEqual name="mod2" value="0">
<!-- stuff for an odd row goes here -->
</logic:notEqual>
</nested:iterate>

The above is from memory so please excuse any minor syntax errors.  When the
<bean:define/> line is processed, an error is generated indicating that
"loop" (our page scope Integer bean set by the nested:iterate tag) is not a
valid variable.  However, if I replace <nested:iterate/> with plain
<logic:iterate/> everything works fine.

Am I running into some sort of scoping issue when I use <nested:iterate/>?

Any help would be much appreciated.

Thanks,
-Steve


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: nested:iterate and indexId problems

Posted by Steve Armstrong <sa...@truecontext.com>.
Thanks very much for the speedy response!

When I said that <logic:iterate/> worked, I had an "id" attribute in that
particular scenario so perhaps that's why everything was okie-dokie.
Another work around I found was to do the following:

subsitute:

<nested:iterate property="phoneNumbers" indexId="loop">
<bean:define id="mod2" value="<%= Integer.toString(loop.intValue() % 2)
%>"/>

with:

<nested:iterate property="phoneNumbers" indexId="loop">
<bean:define id="row" scope="page" name="loop" type="java.lang.Integer"/>
<bean:define id="mod2" value="<%= Integer.toString(row.intValue() % 2) %>"/>

One more intermediate step, but no biggie.  As to why it works, I'll leave
that mystery up to you bright fellows :-)

Cheers,
-Steve

-----Original Message-----
From: Arron Bates [mailto:arronb@pacific.net.au]
Sent: Friday, May 24, 2002 2:28 AM
To: Struts Users Mailing List
Subject: Re: nested:iterate and indexId problems


Just had a play, and there's a bug in the tag's extra info class around
the indexId.
Until then, set an "id" attribute also, and it should work.

Seems though the extension is troubled by its super class, and it's
looking like a fix is required there also. Either way, I'll sort it out
tonight (few hours from now), so you can download NeXt again tomorrow,
and it'll be sweet. Actually, from looking at the code, it's a surprise
that common <logic:iterate> tags aren't suffering from the same issue.


Arron.

Steve Armstrong wrote:

>Hi,
>
>I'm using Struts 1.0.2 with the NeXt package targeted for that particular
>load.  I'm having a problem evaluating the page scope Integer bean that
>should be created via the indexId attribute.
>
>Inside an <html:form>, I have something like the following for handling odd
>and even rows of a table differently:
>
><nested:iterate property="phoneNumbers" indexId="loop">
><bean:define id="mod2" value="<%= Integer.toString(loop.intValue() % 2)
>%>"/>
><logic:equal name="mod2" value="0">
><!-- stuff for an even row goes here -->
></logic:equal>
><logic:notEqual name="mod2" value="0">
><!-- stuff for an odd row goes here -->
></logic:notEqual>
></nested:iterate>
>
>The above is from memory so please excuse any minor syntax errors.  When
the
><bean:define/> line is processed, an error is generated indicating that
>"loop" (our page scope Integer bean set by the nested:iterate tag) is not a
>valid variable.  However, if I replace <nested:iterate/> with plain
><logic:iterate/> everything works fine.
>
>Am I running into some sort of scoping issue when I use <nested:iterate/>?
>
>Any help would be much appreciated.
>
>Thanks,
>-Steve



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: nested:iterate and indexId problems

Posted by Arron Bates <ar...@pacific.net.au>.
Just had a play, and there's a bug in the tag's extra info class around 
the indexId.
Until then, set an "id" attribute also, and it should work.

Seems though the extension is troubled by its super class, and it's 
looking like a fix is required there also. Either way, I'll sort it out 
tonight (few hours from now), so you can download NeXt again tomorrow, 
and it'll be sweet. Actually, from looking at the code, it's a surprise 
that common <logic:iterate> tags aren't suffering from the same issue.


Arron.

Steve Armstrong wrote:

>Hi,
>
>I'm using Struts 1.0.2 with the NeXt package targeted for that particular
>load.  I'm having a problem evaluating the page scope Integer bean that
>should be created via the indexId attribute.
>
>Inside an <html:form>, I have something like the following for handling odd
>and even rows of a table differently:
>
><nested:iterate property="phoneNumbers" indexId="loop">
><bean:define id="mod2" value="<%= Integer.toString(loop.intValue() % 2)
>%>"/>
><logic:equal name="mod2" value="0">
><!-- stuff for an even row goes here -->
></logic:equal>
><logic:notEqual name="mod2" value="0">
><!-- stuff for an odd row goes here -->
></logic:notEqual>
></nested:iterate>
>
>The above is from memory so please excuse any minor syntax errors.  When the
><bean:define/> line is processed, an error is generated indicating that
>"loop" (our page scope Integer bean set by the nested:iterate tag) is not a
>valid variable.  However, if I replace <nested:iterate/> with plain
><logic:iterate/> everything works fine.
>
>Am I running into some sort of scoping issue when I use <nested:iterate/>?
>
>Any help would be much appreciated.
>
>Thanks,
>-Steve
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>