You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vinod Kumar <vk...@yahoo.com> on 2006/10/13 00:29:02 UTC
iterating of collection of HashMapsusing logic:iterate
Hi All,
I have hashmap with key/value but the value in this
hashmap is another hashmap.
How can I iterate over all the values using
logic:iterate.
HashMap h1 = new HashMap();
String id=1;
HashMap h2 = new HashMap();
h2.put(id,"123");
h2.put("key1","456");
h2.put("key2","789");
then I make entry to h1 like
h1.put(id,h2) and so on...more entries added to h1.
Now I want to iterate thru all the values of h1.
Please note that I am interested only in values of the
h2 and NOT the keys.
Thanks in advance for your help
Vinod
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: iterating of collection of HashMapsusing logic:iterate
Posted by "Pradyumna kumar, Jena (J.)" <jp...@ford.com>.
or
in the inner iterate have both name set to entry and property to value
________________________________
From: Vinod Kumar [mailto:vkmatri@yahoo.com]
Sent: Fri 10/13/2006 6:29 AM
To: user@struts.apache.org
Subject: iterating of collection of HashMapsusing logic:iterate
Hi All,
I have hashmap with key/value but the value in this
hashmap is another hashmap.
How can I iterate over all the values using
logic:iterate.
HashMap h1 = new HashMap();
String id=1;
HashMap h2 = new HashMap();
h2.put(id,"123");
h2.put("key1","456");
h2.put("key2","789");
then I make entry to h1 like
h1.put(id,h2) and so on...more entries added to h1.
Now I want to iterate thru all the values of h1.
Please note that I am interested only in values of the
h2 and NOT the keys.
Thanks in advance for your help
Vinod
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: iterating of collection of HashMapsusing logic:iterate
Posted by Vinod Kumar <vk...@yahoo.com>.
Thanks Pradyumna !! I am able to make it work as
suggested by you.
Thanks
Vinod
--- "Pradyumna kumar, Jena (J.)" <jp...@ford.com>
wrote:
> try somethin like this....
>
> <logic:iterate id="currentEntry" collection="h1">
>
> <%
>
> Map cuurentMap=((Map.Entry
> )currentEntry).getvalue();
>
> PageContext.setAttribute("cuurentMap",cuurentMap);
>
> %>
>
> <logic:iterate id="currentvalue"
> collection="cuurentMap">
>
> // here u need to process the entries
>
> </logic:iterate>
>
> </logic:iterate>
>
>
> ________________________________
>
> From: Vinod Kumar [mailto:vkmatri@yahoo.com]
> Sent: Fri 10/13/2006 6:29 AM
> To: user@struts.apache.org
> Subject: iterating of collection of HashMapsusing
> logic:iterate
>
>
>
> Hi All,
> I have hashmap with key/value but the value in this
> hashmap is another hashmap.
> How can I iterate over all the values using
> logic:iterate.
>
> HashMap h1 = new HashMap();
>
> String id=1;
> HashMap h2 = new HashMap();
> h2.put(id,"123");
> h2.put("key1","456");
> h2.put("key2","789");
>
> then I make entry to h1 like
>
> h1.put(id,h2) and so on...more entries added to h1.
>
> Now I want to iterate thru all the values of h1.
>
> Please note that I am interested only in values of
> the
> h2 and NOT the keys.
>
> Thanks in advance for your help
>
> Vinod
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
>
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: iterating of collection of HashMapsusing logic:iterate
Posted by "Pradyumna kumar, Jena (J.)" <jp...@ford.com>.
try somethin like this....
<logic:iterate id="currentEntry" collection="h1">
<%
Map cuurentMap=((Map.Entry )currentEntry).getvalue();
PageContext.setAttribute("cuurentMap",cuurentMap);
%>
<logic:iterate id="currentvalue" collection="cuurentMap">
// here u need to process the entries
</logic:iterate>
</logic:iterate>
________________________________
From: Vinod Kumar [mailto:vkmatri@yahoo.com]
Sent: Fri 10/13/2006 6:29 AM
To: user@struts.apache.org
Subject: iterating of collection of HashMapsusing logic:iterate
Hi All,
I have hashmap with key/value but the value in this
hashmap is another hashmap.
How can I iterate over all the values using
logic:iterate.
HashMap h1 = new HashMap();
String id=1;
HashMap h2 = new HashMap();
h2.put(id,"123");
h2.put("key1","456");
h2.put("key2","789");
then I make entry to h1 like
h1.put(id,h2) and so on...more entries added to h1.
Now I want to iterate thru all the values of h1.
Please note that I am interested only in values of the
h2 and NOT the keys.
Thanks in advance for your help
Vinod
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: iterating of collection of HashMapsusing logic:iterate
Posted by Vinod Kumar <vk...@yahoo.com>.
Thanks Puneet. I will try your solution as well.
vinod
--- Puneet Lakhina <pu...@gmail.com> wrote:
> On 10/13/06, Vinod Kumar <vk...@yahoo.com> wrote:
> >
> > Hi All,
> > I have hashmap with key/value but the value in
> this
> > hashmap is another hashmap.
> > How can I iterate over all the values using
> > logic:iterate.
> >
> > HashMap h1 = new HashMap();
> >
> > String id=1;
> > HashMap h2 = new HashMap();
> > h2.put(id,"123");
> > h2.put("key1","456");
> > h2.put("key2","789");
> >
> > then I make entry to h1 like
> >
> > h1.put(id,h2) and so on...more entries added to
> h1.
> >
> > Now I want to iterate thru all the values of h1.
> >
> > Please note that I am interested only in values of
> the
> > h2 and NOT the keys.
>
>
> Well If you would like to avoid scriptlets(which is
> what is suggested in the
> second mail by Pradyumna then you could simple do...
>
> <logic:iterate name="h1Attribute" id="entry">
> <logic:iterate name="entry" property="value"
> id="h2Entry">
> <bean:write name="h2Entry" property=value />
> </logic:iterate>
> </logic:iterate>
>
>
> Thanks in advance for your help
> >
> > Vinod
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> > For additional commands, e-mail:
> user-help@struts.apache.org
> >
> >
>
>
> --
> Puneet
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: iterating of collection of HashMapsusing logic:iterate
Posted by Puneet Lakhina <pu...@gmail.com>.
On 10/13/06, Vinod Kumar <vk...@yahoo.com> wrote:
>
> Hi All,
> I have hashmap with key/value but the value in this
> hashmap is another hashmap.
> How can I iterate over all the values using
> logic:iterate.
>
> HashMap h1 = new HashMap();
>
> String id=1;
> HashMap h2 = new HashMap();
> h2.put(id,"123");
> h2.put("key1","456");
> h2.put("key2","789");
>
> then I make entry to h1 like
>
> h1.put(id,h2) and so on...more entries added to h1.
>
> Now I want to iterate thru all the values of h1.
>
> Please note that I am interested only in values of the
> h2 and NOT the keys.
Well If you would like to avoid scriptlets(which is what is suggested in the
second mail by Pradyumna then you could simple do...
<logic:iterate name="h1Attribute" id="entry">
<logic:iterate name="entry" property="value" id="h2Entry">
<bean:write name="h2Entry" property=value />
</logic:iterate>
</logic:iterate>
Thanks in advance for your help
>
> Vinod
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Puneet