struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: S2 NESTED iterators & FLAT HashMaps:
Date Mon, 18 Feb 2008 18:09:53 GMT
 > fruits KEY <s:property value="#fruitsId.key" />

Gets the key from the map entry and displays it; OK here.

 > fruits Val <s:text name="%{fruitsStat.value}" />

Gets the 'value' property of the iterator status object and uses that as 
a lookup key in the application's message resources. Umm... First, I'm 
not sure if the iterator status object has a value property, but 
wouldn't you want the value from the map entry? And second, do you have 
the message properties set up?

That should probably be

     fruits Val <s:text name="%{fruitsId.value}" />

and, for sanity checing (in case your message resources aren't set up 
correctly) you should start with just

     fruits Val <s:property value="%{fruitsId.value}" />

L.

Ravichandra C wrote:
> Hi,
> 
> I am trying this way:
> 
> 
> 	<s:iterator id="fruitsId" status="fruitsStat"
> value="fruitscolourandInfo" >
> 			fruits KEY <s:property value="#fruitsId.key" />
> <colour/>
> 			fruits Val <s:text name="%{fruitsStat.value}" />
> <colour/>
> 		<s:iterator id="colourId" status="colourStatus"
> value="fruitsId.value" >
> 			colour <s:text name="%{top.value}" /> <colour/>
> 		</s:iterator>
> 	</s:iterator>
> 
> The issue is that:
> Fruits key: is being displayed fine
> Fruits Val: nothing is being dislayed; infact when I tried similarly
> with fruits KEY even that is not being displayed. Any ideas how to get
> this working.. (in fact I need to get the results in textboxes next)	
> 
> Any help?
> Ravi 
> 
> -----Original Message-----
> From: Musachy Barroso [mailto:musachy@gmail.com] 
> Sent: Monday, February 18, 2008 10:09 PM
> To: Struts Users Mailing List
> Subject: Re: S2 NESTED iterators & FLAT HashMaps:
> 
> When you use the "iterator" tag, the value of the "id" tag becomes the
> reference to the current object on that iteration(same as "top" on
> this case). When iterating over a map, the object is a Map.Entry, so
> you need to access the "key" and "value" properties, like
> 
> <s:iterator id="superMap" value="myMap">
>     Key: <s:property value="superMap.key" /> ....same as <s:property
> value="key" />
>     Value: <s:property value="superMap.value" />....same as
> <s:property value="value" />
> </s:iterator>
> 
> is not a direct answer to your question, but I think your problem is
> around that.
> //you can always do %{superMap[top.key]} to access the value, it is
> just harder to read
> 
> regards
> musachy
> 
> On Feb 18, 2008 11:21 AM, ravi_eze <ravichandrac@ivycomptech.com> wrote:
>> hi,
>>
>> i have 4 hashmaps as follows:
>> (1). HashMap<String, HashSet<String>> treesFruitsMap = new HashMap();
>> (2). HashMap<String, HashSet<String>> fruitsColourMap = new HashMap();
>> (3). HashMap<String, String> colourVitaminMap = new HashMap();
>>
>> i.e.
>> (1) has the mapping btw tree names and the fruits it bears (as a set
> of
>> strings)
>> (2) has the mapping btw fruit name and the possible colours it can
> come out
>> in
>> (3) mapping btw fruit and the vitamins it has in it.
>>
>> I need to display the output as follows:
>> Fruit1 - Colour1 - Vitamin1
>> Fruit1 - Colour1 - Vitamin2
>> Fruit1 - Colour2 - < corresponding vitamins >
>> ...
>>
>> any idea how to go with this? I tried as follows but its not working..
>>
>>         <s:iterator id="frId" status="frStat"
> value="frColourMap.keySet()" >
>>                 <s:iterator id="coId" status="coStatus" value="top" >
>>                         FE <s:text name="%{top}" /> <br/>
>>                         BR <s:text name="%{coStatus[top]}" /> <br/>
>>                 </s:iterator>
>>         </s:iterator>
>>
>> this is giving only the fruits names but not the colours...
>>
>> pl: help.
>>
>> --
>> View this message in context:
> http://www.nabble.com/S2-NESTED-iterators---FLAT-HashMaps%3A-tp15546918p
> 15546918.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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


Mime
View raw message