You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dinesh B sampangi <di...@hotmail.com> on 2003/05/19 15:06:29 UTC
conditional iteration based on index value
hi! All,
i need to iterate conditionally based on the index value, how can this be achieved.
for eg. i need to output some values if the index is 0 & not output the same if the index is > 1;
and also since i'm using nested:iterate how can this be done..
TIA
Dinesh
Re: conditional iteration based on index value
Posted by Mark Lowe <ma...@talk21.com>.
hi Dinesh
I assume you're talking to me :o) I generally prefer Mark..
anyway i'm a little confused what you are doing is ABC and list
contained within the XYZ list?
i guess that could be irrelevant. So you've an ABC list thats stored in
XYZ at an index of 0.
The nested tags already indexed the properties, have you tried name
rather than property?
<nested:equal name="myIndex" value="0">
Do something with list...
<nested:equal>
i'll have to look though some stuff as I haven't used nested tags for a
while.
without nested tags
<logic:iterate id="foo" name="XYZ" indexId="myIndex">
<logic:equal name="myIndex" value="0">
do some thing...
</logic:equal>
</logic:iterate>
I think the problem is that myIndex isn't a property of XYZ but a
counter defined in the page context (i could be wrong). so you
reference it as an object in the page scope.
cheers mark
Lunedì, 19 mag 2003, alle 16:44 Europe/London, Dinesh B sampangi ha
scritto:
> Hi Lowe,
> i'm getting the following exception:
>
> javax.servlet.jsp.JspException: Exception accessing property
> XYZ[0].myIndex for bean ItemCostingForm:
> java.lang.NoSuchMethodException:
> Unknown property 'myIndex'
>
> this is my jsp code snippet:
> <nested:iterate property = "XYZ" indexId="myIndex">
> <nested:equal property="myIndex" value="0">
> < nested:iterate property="ABC">
> . ....
> </nested:iterate>
> <nested:equal>
> </nested:iterate>
>
> so..whats u'r opinion on this
>
> TIA
> Dinesh
>
>
> ----- Original Message -----
> From: "Mark Lowe" <ma...@talk21.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Monday, May 19, 2003 6:37 PM
> Subject: Re: conditional iteration based on index value
>
>
>
> Some thing along these lines, the docs are pretty straight forward on
> this..
>
> <nested:iterate name="myIterator" indexId="myIndex">
> < nested:equal property="myIndex" value="0">
> You can see this cos the index is 0
> </nested: equal >
>
> etc....
>
> </nested:iterate>
>
> cheers mark
>
> Lunedì, 19 mag 2003, alle 14:06 Europe/London, Dinesh B sampangi ha
> scritto:
>
>> hi! All,
>> i need to iterate conditionally based on the index value, how can
>> this be achieved.
>>
>> for eg. i need to output some values if the index is 0 & not output
>> the same if the index is > 1;
>> and also since i'm using nested:iterate how can this be done..
>>
>>
>> TIA
>> Dinesh
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: conditional iteration based on index value
Posted by Dinesh B sampangi <di...@hotmail.com>.
Hi Lowe,
i'm getting the following exception:
javax.servlet.jsp.JspException: Exception accessing property
XYZ[0].myIndex for bean ItemCostingForm: java.lang.NoSuchMethodException:
Unknown property 'myIndex'
this is my jsp code snippet:
<nested:iterate property = "XYZ" indexId="myIndex">
<nested:equal property="myIndex" value="0">
< nested:iterate property="ABC">
. ....
</nested:iterate>
<nested:equal>
</nested:iterate>
so..whats u'r opinion on this
TIA
Dinesh
----- Original Message -----
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, May 19, 2003 6:37 PM
Subject: Re: conditional iteration based on index value
Some thing along these lines, the docs are pretty straight forward on
this..
<nested:iterate name="myIterator" indexId="myIndex">
< nested:equal property="myIndex" value="0">
You can see this cos the index is 0
</nested: equal >
etc....
</nested:iterate>
cheers mark
Lunedì, 19 mag 2003, alle 14:06 Europe/London, Dinesh B sampangi ha
scritto:
> hi! All,
> i need to iterate conditionally based on the index value, how can
> this be achieved.
>
> for eg. i need to output some values if the index is 0 & not output
> the same if the index is > 1;
> and also since i'm using nested:iterate how can this be done..
>
>
> TIA
> Dinesh
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: conditional iteration based on index value
Posted by Mark Lowe <ma...@talk21.com>.
Some thing along these lines, the docs are pretty straight forward on
this..
<nested:iterate name="myIterator" indexId="myIndex">
< nested:equal property="myIndex" value="0">
You can see this cos the index is 0
</nested: equal >
etc....
</nested:iterate>
cheers mark
Lunedì, 19 mag 2003, alle 14:06 Europe/London, Dinesh B sampangi ha
scritto:
> hi! All,
> i need to iterate conditionally based on the index value, how can
> this be achieved.
>
> for eg. i need to output some values if the index is 0 & not output
> the same if the index is > 1;
> and also since i'm using nested:iterate how can this be done..
>
>
> TIA
> Dinesh
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org