You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Thomas Lulé <th...@lule.fr> on 2010/05/11 11:39:54 UTC

Iterate over an ArrayList of arrays

Hi,

I've got an ArrayList<String[]> named "breadcrumbs" in my action that
I would like to display in my JSP.

Something like :
	<ul>
		<s:iterator value="breadcrumbs">
			<li><a href="${value[1]}">${value[0]}</a></li>
		</s:iterator>
	</ul>
I want to iterate over the ArrayList, then get the two values of the
array, but this code obviously doesn't work.

Do you have any better idea ?

Thank you,
Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Iterate over an ArrayList of arrays

Posted by Thomas Lulé <th...@lule.fr>.
It works !

Thank you very much.

2010/5/11 Steven Yang <ke...@gmail.com>:
> try
> <s:iterator value="breadcrumbs">
>                       <li><a href="${top[1]}">${top[0]}</a></li>
>               </s:iterator>
>
> On Tue, May 11, 2010 at 5:52 PM, Thomas Lulé <th...@lule.fr> wrote:
>
>> I just found an ugly solution :
>>
>>        <ul>
>>                <s:iterator value="breadcrumbs">
>>                         <s:iterator status="stat">
>>                                <s:if test="#stat.index==0">
>>                                        <s:set name="text"><s:property
>> /></s:set>
>>                                </s:if>
>>                                <s:else>
>>                                        <s:set name="url"><s:property
>> /></s:set>
>>                                </s:else>
>>                        </s:iterator>
>>                        <li><a href="${url}">${text}</a></li>
>>                </s:iterator>
>>        </ul>
>>
>> 2010/5/11 Thomas Lulé <th...@lule.fr>:
>> > Hi,
>> >
>> > I've got an ArrayList<String[]> named "breadcrumbs" in my action that
>> > I would like to display in my JSP.
>> >
>> > Something like :
>> >        <ul>
>> >                <s:iterator value="breadcrumbs">
>> >                        <li><a href="${value[1]}">${value[0]}</a></li>
>> >                </s:iterator>
>> >        </ul>
>> > I want to iterate over the ArrayList, then get the two values of the
>> > array, but this code obviously doesn't work.
>> >
>> > Do you have any better idea ?
>> >
>> > Thank you,
>> > Thomas
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Iterate over an ArrayList of arrays

Posted by Martin Gainty <mg...@hotmail.com>.
xwork refers to top of stack as @vs

defined as "the class for the object on the top of the stack "


http://struts.apache.org/2.0.14/docs/ognl-basics.html

 

hth
Martin 
______________________________________________ 
please do not alter/modify or disrupt this transmission. Thank You


 


> Date: Tue, 11 May 2010 09:22:44 -0500
> Subject: Re: Iterate over an ArrayList of arrays
> From: elephantium@gmail.com
> To: user@struts.apache.org
> 
> It just refers to the top of the value stack.
> 
> -Brian
> 
> 
> 
> On Tue, May 11, 2010 at 9:17 AM, James Cook <Ja...@wecomm.com> wrote:
> > Where does 'top' come from?
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
 		 	   		  
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2

Re: Iterate over an ArrayList of arrays

Posted by Brian Thompson <el...@gmail.com>.
It just refers to the top of the value stack.

-Brian



On Tue, May 11, 2010 at 9:17 AM, James Cook <Ja...@wecomm.com> wrote:
> Where does 'top' come from?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Iterate over an ArrayList of arrays

Posted by James Cook <Ja...@wecomm.com>.
Where does 'top' come from?

-----Original Message-----
From: Dale Newfield [mailto:dale@newfield.org] 
Sent: 11 May 2010 14:49
To: Struts Users Mailing List
Cc: Steven Yang
Subject: Re: Iterate over an ArrayList of arrays

On 5/11/10 5:59 AM, Steven Yang wrote:
> try
> <s:iterator value="breadcrumbs">
>                         <li><a href="${top[1]}">${top[0]}</a></li>
>                 </s:iterator>

Except you're using EL here to access OGNL.  I'd suggest this is
cleaner:

<s:iterator value="breadcrumbs">
   <li><a href="<s:property value='%{top[1]}'/>"><s:property 
value="%{top[0]}"/></a></li>
</s:iterator>

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Iterate over an ArrayList of arrays

Posted by Dale Newfield <da...@newfield.org>.
On 5/11/10 5:59 AM, Steven Yang wrote:
> try
> <s:iterator value="breadcrumbs">
>                         <li><a href="${top[1]}">${top[0]}</a></li>
>                 </s:iterator>

Except you're using EL here to access OGNL.  I'd suggest this is cleaner:

<s:iterator value="breadcrumbs">
   <li><a href="<s:property value='%{top[1]}'/>"><s:property 
value="%{top[0]}"/></a></li>
</s:iterator>

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Iterate over an ArrayList of arrays

Posted by Steven Yang <ke...@gmail.com>.
try
<s:iterator value="breadcrumbs">
                       <li><a href="${top[1]}">${top[0]}</a></li>
               </s:iterator>

On Tue, May 11, 2010 at 5:52 PM, Thomas Lulé <th...@lule.fr> wrote:

> I just found an ugly solution :
>
>        <ul>
>                <s:iterator value="breadcrumbs">
>                         <s:iterator status="stat">
>                                <s:if test="#stat.index==0">
>                                        <s:set name="text"><s:property
> /></s:set>
>                                </s:if>
>                                <s:else>
>                                        <s:set name="url"><s:property
> /></s:set>
>                                </s:else>
>                        </s:iterator>
>                        <li><a href="${url}">${text}</a></li>
>                </s:iterator>
>        </ul>
>
> 2010/5/11 Thomas Lulé <th...@lule.fr>:
> > Hi,
> >
> > I've got an ArrayList<String[]> named "breadcrumbs" in my action that
> > I would like to display in my JSP.
> >
> > Something like :
> >        <ul>
> >                <s:iterator value="breadcrumbs">
> >                        <li><a href="${value[1]}">${value[0]}</a></li>
> >                </s:iterator>
> >        </ul>
> > I want to iterate over the ArrayList, then get the two values of the
> > array, but this code obviously doesn't work.
> >
> > Do you have any better idea ?
> >
> > Thank you,
> > Thomas
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Iterate over an ArrayList of arrays

Posted by Thomas Lulé <th...@lule.fr>.
I just found an ugly solution :

	<ul>
		<s:iterator value="breadcrumbs">
			<s:iterator status="stat">
				<s:if test="#stat.index==0">
					<s:set name="text"><s:property /></s:set>
				</s:if>
				<s:else>
					<s:set name="url"><s:property /></s:set>
				</s:else>
			</s:iterator>
			<li><a href="${url}">${text}</a></li>
		</s:iterator>
	</ul>

2010/5/11 Thomas Lulé <th...@lule.fr>:
> Hi,
>
> I've got an ArrayList<String[]> named "breadcrumbs" in my action that
> I would like to display in my JSP.
>
> Something like :
>        <ul>
>                <s:iterator value="breadcrumbs">
>                        <li><a href="${value[1]}">${value[0]}</a></li>
>                </s:iterator>
>        </ul>
> I want to iterate over the ArrayList, then get the two values of the
> array, but this code obviously doesn't work.
>
> Do you have any better idea ?
>
> Thank you,
> Thomas
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org