Re: Iterate Hashmap with s:iterate
Example code: On 9/21/07, Dave Newton <[EMAIL PROTECTED]> wrote: > > --- j alex <[EMAIL PROTECTED]> wrote: > > > > The entire expresion is OGNL, not just the "key" value > from the stack. > > d. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Iterate Hashmap with s:iterate
--- j alex <[EMAIL PROTECTED]> wrote: > The entire expresion is OGNL, not just the "key" value from the stack. d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Iterate Hashmap with s:iterate
I'm not able to use the key within an s:if condition though.. Code : It prints out the correct value in else condition but the comparison fails ; please help! -Joseph On 9/12/07, Cory D. Wiles <[EMAIL PROTECTED]> wrote: > > That worked perfectly. Thanks everyone for all the help. > > -Cory > > On 9/12/07, Josh Vickery <[EMAIL PROTECTED]> wrote: > > > > Looking through some code here, this is what I have: > > > > > > > > > > > > > > The above seems to work OK, though I'm a little curious about the > > inclusion of the double parentheses at the end of "entrySet" -- OGNL, > > as far as I am concerned, is a bit of strange beast. > > > > Josh > > > > On 9/12/07, Cory D. Wiles <[EMAIL PROTECTED]> wrote: > > > It is still not working the way that I want to, but I do appreciate > the > > > help. I'll just have to keep plugging away at it. > > > > > > Thanks, > > > Cory > > > > > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> wrote: > > > > > > > > The OGNL manual. > > > > > > > > > http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html > > > > > > > > --- "Cory D. Wiles" <[EMAIL PROTECTED]> wrote: > > > > > > > > > Dave, > > > > > Where did you find the documentation on the > > > > > "pseudo-property"? > > > > > > > > > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> > > > > > wrote: > > > > > > > > > > > > IIRC OGNL supplies a pseudo-property "keys" that > > > > > will > > > > > > return a list of keys present in the map. > > > > > > > > > > > > --- Wesley Wannemacher <[EMAIL PROTECTED]> > > > > > > wrote: > > > > > > > > > > > > > If I remember correctly, to use the s:iterator > > > > > tag, > > > > > > > you have to use an > > > > > > > object that has an 'iterator()' method. HashMap > > > > > does > > > > > > > not implement > > > > > > > java.util.List... > > > > > > > > > > > > > > To iterate over a Hashmap, get the keyset > > > > > > > [tempMap.ketSet()] from it. > > > > > > > The keyset is a List and you can get an iterator > > > > > > > from there. > > > > > > > > > > > > > > -Wes > > > > > > > > > > > > > > -Original Message- > > > > > > > From: Cory D. Wiles [mailto:[EMAIL PROTECTED] > > > > > > > Sent: Wednesday, September 12, 2007 2:28 PM > > > > > > > To: user@struts.apache.org > > > > > > > Subject: Iterate Hashmap with s:iterate > > > > > > > > > > > > > > I have an action that returns a hash map that I > > > > > need > > > > > > > to output both the > > > > > > > key and value, but I can't figure out how to > > > > > access > > > > > > > each property with > > > > > > > s:iterate. Any suggestions would help. > > > > > > > > > > > > > > The HashMap is being set in my action and > > > > > returned > > > > > > > populated (verified > > > > > > > with ). > > > > > > > > > > > > > > // Action snippet > > > > > > > Iterator categoryPhysPropsItr = > > > > > > > getCategoryPhysProps().iterator(); > > > > > > > Map tempMap = new > > > > > HashMap(); > > > > > > > tempMap = new > > > > > > > TreeMap(); > > > > > > > > > > > > > > while (categoryPhysPropsItr.hasNext()) { > > > > > > > DruglistDrugproperty prop = new > > > > > > > DruglistDrugproperty(); > > > > > > > prop = (DruglistDrugproperty) > > > > > > > categoryPhysPropsItr.next(); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), > > > > > > > prop.getDrugService()); > > > > > > > > > > > > > > } > > > > > > > > > > > > > > setDrugClassPropsSrvc(tempMap); // HashMap > > > > > > > that needs to be > > > > > > > iterated through // end Action Snippet > > > > > > > > > > > > > > // Display JSP > > > > > > > > > > > > > status="status"> > > > > > > > Key ( > > > > > > > > > > > > > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}/>") > > > > > > > Value ( > > > > > > > > > > > > > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}"/>) > > > > > > > > > > > > > > > > > > > > > > > > > > > > // end Display JSP > > > > > > > > > > > > > > Thanks, > > > > > > > Cory > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > - > > > > > > > To unsubscribe, e-mail: > > > > > > > [EMAIL PROTECTED] > > > > > > > For additional commands, e-mail: > > > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > - > > > > > > To unsubscribe, e-mail: > > > > > [EMAIL PROTECTED] > > > > > > For additional commands, e-mail: > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > - > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > ---
Re: Iterate Hashmap with s:iterate
That worked perfectly. Thanks everyone for all the help. -Cory On 9/12/07, Josh Vickery <[EMAIL PROTECTED]> wrote: > > Looking through some code here, this is what I have: > > > > > > > The above seems to work OK, though I'm a little curious about the > inclusion of the double parentheses at the end of "entrySet" -- OGNL, > as far as I am concerned, is a bit of strange beast. > > Josh > > On 9/12/07, Cory D. Wiles <[EMAIL PROTECTED]> wrote: > > It is still not working the way that I want to, but I do appreciate the > > help. I'll just have to keep plugging away at it. > > > > Thanks, > > Cory > > > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> wrote: > > > > > > The OGNL manual. > > > > > > http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html > > > > > > --- "Cory D. Wiles" <[EMAIL PROTECTED]> wrote: > > > > > > > Dave, > > > > Where did you find the documentation on the > > > > "pseudo-property"? > > > > > > > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> > > > > wrote: > > > > > > > > > > IIRC OGNL supplies a pseudo-property "keys" that > > > > will > > > > > return a list of keys present in the map. > > > > > > > > > > --- Wesley Wannemacher <[EMAIL PROTECTED]> > > > > > wrote: > > > > > > > > > > > If I remember correctly, to use the s:iterator > > > > tag, > > > > > > you have to use an > > > > > > object that has an 'iterator()' method. HashMap > > > > does > > > > > > not implement > > > > > > java.util.List... > > > > > > > > > > > > To iterate over a Hashmap, get the keyset > > > > > > [tempMap.ketSet()] from it. > > > > > > The keyset is a List and you can get an iterator > > > > > > from there. > > > > > > > > > > > > -Wes > > > > > > > > > > > > -Original Message- > > > > > > From: Cory D. Wiles [mailto:[EMAIL PROTECTED] > > > > > > Sent: Wednesday, September 12, 2007 2:28 PM > > > > > > To: user@struts.apache.org > > > > > > Subject: Iterate Hashmap with s:iterate > > > > > > > > > > > > I have an action that returns a hash map that I > > > > need > > > > > > to output both the > > > > > > key and value, but I can't figure out how to > > > > access > > > > > > each property with > > > > > > s:iterate. Any suggestions would help. > > > > > > > > > > > > The HashMap is being set in my action and > > > > returned > > > > > > populated (verified > > > > > > with ). > > > > > > > > > > > > // Action snippet > > > > > > Iterator categoryPhysPropsItr = > > > > > > getCategoryPhysProps().iterator(); > > > > > > Map tempMap = new > > > > HashMap(); > > > > > > tempMap = new > > > > > > TreeMap(); > > > > > > > > > > > > while (categoryPhysPropsItr.hasNext()) { > > > > > > DruglistDrugproperty prop = new > > > > > > DruglistDrugproperty(); > > > > > > prop = (DruglistDrugproperty) > > > > > > categoryPhysPropsItr.next(); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), > > > > > > prop.getDrugService()); > > > > > > > > > > > > } > > > > > > > > > > > > setDrugClassPropsSrvc(tempMap); // HashMap > > > > > > that needs to be > > > > > > iterated through // end Action Snippet > > > > > > > > > > > > // Display JSP > > > > > > > > > > > status="status"> > > > > > > Key ( > > > > > > > > > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}/>") > > > > > > Value ( > > > > > > > > > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}"/>) > > > > > > > > > > > > > > > > > > > > > > > > // end Display JSP > > > > > > > > > > > > Thanks, > > > > > > Cory > > > > > > > > > > > > > > > > > > > > > > > > - > > > > > > To unsubscribe, e-mail: > > > > > > [EMAIL PROTECTED] > > > > > > For additional commands, e-mail: > > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > - > > > > > To unsubscribe, e-mail: > > > > [EMAIL PROTECTED] > > > > > For additional commands, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Iterate Hashmap with s:iterate
--- Josh Vickery <[EMAIL PROTECTED]> wrote: > I'm a little curious about the inclusion of the > double parentheses at the end of "entrySet" -- OGNL, > as far as I am concerned, is a bit of strange beast. It's a method call -- not property access. d. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Iterate Hashmap with s:iterate
Looking through some code here, this is what I have: The above seems to work OK, though I'm a little curious about the inclusion of the double parentheses at the end of "entrySet" -- OGNL, as far as I am concerned, is a bit of strange beast. Josh On 9/12/07, Cory D. Wiles <[EMAIL PROTECTED]> wrote: > It is still not working the way that I want to, but I do appreciate the > help. I'll just have to keep plugging away at it. > > Thanks, > Cory > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> wrote: > > > > The OGNL manual. > > > > http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html > > > > --- "Cory D. Wiles" <[EMAIL PROTECTED]> wrote: > > > > > Dave, > > > Where did you find the documentation on the > > > "pseudo-property"? > > > > > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> > > > wrote: > > > > > > > > IIRC OGNL supplies a pseudo-property "keys" that > > > will > > > > return a list of keys present in the map. > > > > > > > > --- Wesley Wannemacher <[EMAIL PROTECTED]> > > > > wrote: > > > > > > > > > If I remember correctly, to use the s:iterator > > > tag, > > > > > you have to use an > > > > > object that has an 'iterator()' method. HashMap > > > does > > > > > not implement > > > > > java.util.List... > > > > > > > > > > To iterate over a Hashmap, get the keyset > > > > > [tempMap.ketSet()] from it. > > > > > The keyset is a List and you can get an iterator > > > > > from there. > > > > > > > > > > -Wes > > > > > > > > > > -Original Message- > > > > > From: Cory D. Wiles [mailto:[EMAIL PROTECTED] > > > > > Sent: Wednesday, September 12, 2007 2:28 PM > > > > > To: user@struts.apache.org > > > > > Subject: Iterate Hashmap with s:iterate > > > > > > > > > > I have an action that returns a hash map that I > > > need > > > > > to output both the > > > > > key and value, but I can't figure out how to > > > access > > > > > each property with > > > > > s:iterate. Any suggestions would help. > > > > > > > > > > The HashMap is being set in my action and > > > returned > > > > > populated (verified > > > > > with ). > > > > > > > > > > // Action snippet > > > > > Iterator categoryPhysPropsItr = > > > > > getCategoryPhysProps().iterator(); > > > > > Map tempMap = new > > > HashMap(); > > > > > tempMap = new > > > > > TreeMap(); > > > > > > > > > > while (categoryPhysPropsItr.hasNext()) { > > > > > DruglistDrugproperty prop = new > > > > > DruglistDrugproperty(); > > > > > prop = (DruglistDrugproperty) > > > > > categoryPhysPropsItr.next(); > > > > > > > > > > > > > > > > > > > > > > > > tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), > > > > > prop.getDrugService()); > > > > > > > > > > } > > > > > > > > > > setDrugClassPropsSrvc(tempMap); // HashMap > > > > > that needs to be > > > > > iterated through // end Action Snippet > > > > > > > > > > // Display JSP > > > > > > > > > status="status"> > > > > > Key ( > > > > > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}/>") > > > > > Value ( > > > > > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}"/>) > > > > > > > > > > > > > > > > > > > > // end Display JSP > > > > > > > > > > Thanks, > > > > > Cory > > > > > > > > > > > > > > > > > > > - > > > > > To unsubscribe, e-mail: > > > > > [EMAIL PROTECTED] > > > > > For additional commands, e-mail: > > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > > > > > > > > - > > > > To unsubscribe, e-mail: > > > [EMAIL PROTECTED] > > > > For additional commands, e-mail: > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Iterate Hashmap with s:iterate
It is still not working the way that I want to, but I do appreciate the help. I'll just have to keep plugging away at it. Thanks, Cory On 9/12/07, Dave Newton <[EMAIL PROTECTED]> wrote: > > The OGNL manual. > > http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html > > --- "Cory D. Wiles" <[EMAIL PROTECTED]> wrote: > > > Dave, > > Where did you find the documentation on the > > "pseudo-property"? > > > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> > > wrote: > > > > > > IIRC OGNL supplies a pseudo-property "keys" that > > will > > > return a list of keys present in the map. > > > > > > --- Wesley Wannemacher <[EMAIL PROTECTED]> > > > wrote: > > > > > > > If I remember correctly, to use the s:iterator > > tag, > > > > you have to use an > > > > object that has an 'iterator()' method. HashMap > > does > > > > not implement > > > > java.util.List... > > > > > > > > To iterate over a Hashmap, get the keyset > > > > [tempMap.ketSet()] from it. > > > > The keyset is a List and you can get an iterator > > > > from there. > > > > > > > > -Wes > > > > > > > > -Original Message- > > > > From: Cory D. Wiles [mailto:[EMAIL PROTECTED] > > > > Sent: Wednesday, September 12, 2007 2:28 PM > > > > To: user@struts.apache.org > > > > Subject: Iterate Hashmap with s:iterate > > > > > > > > I have an action that returns a hash map that I > > need > > > > to output both the > > > > key and value, but I can't figure out how to > > access > > > > each property with > > > > s:iterate. Any suggestions would help. > > > > > > > > The HashMap is being set in my action and > > returned > > > > populated (verified > > > > with ). > > > > > > > > // Action snippet > > > > Iterator categoryPhysPropsItr = > > > > getCategoryPhysProps().iterator(); > > > > Map tempMap = new > > HashMap(); > > > > tempMap = new > > > > TreeMap(); > > > > > > > > while (categoryPhysPropsItr.hasNext()) { > > > > DruglistDrugproperty prop = new > > > > DruglistDrugproperty(); > > > > prop = (DruglistDrugproperty) > > > > categoryPhysPropsItr.next(); > > > > > > > > > > > > > > > > > > tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), > > > > prop.getDrugService()); > > > > > > > > } > > > > > > > > setDrugClassPropsSrvc(tempMap); // HashMap > > > > that needs to be > > > > iterated through // end Action Snippet > > > > > > > > // Display JSP > > > > > > > status="status"> > > > > Key ( > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}/>") > > > > Value ( > > > > > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}"/>) > > > > > > > > > > > > > > > > // end Display JSP > > > > > > > > Thanks, > > > > Cory > > > > > > > > > > > > > > - > > > > To unsubscribe, e-mail: > > > > [EMAIL PROTECTED] > > > > For additional commands, e-mail: > > > > [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > > > - > > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Iterate Hashmap with s:iterate
The OGNL manual. http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/index.html --- "Cory D. Wiles" <[EMAIL PROTECTED]> wrote: > Dave, > Where did you find the documentation on the > "pseudo-property"? > > On 9/12/07, Dave Newton <[EMAIL PROTECTED]> > wrote: > > > > IIRC OGNL supplies a pseudo-property "keys" that > will > > return a list of keys present in the map. > > > > --- Wesley Wannemacher <[EMAIL PROTECTED]> > > wrote: > > > > > If I remember correctly, to use the s:iterator > tag, > > > you have to use an > > > object that has an 'iterator()' method. HashMap > does > > > not implement > > > java.util.List... > > > > > > To iterate over a Hashmap, get the keyset > > > [tempMap.ketSet()] from it. > > > The keyset is a List and you can get an iterator > > > from there. > > > > > > -Wes > > > > > > -Original Message- > > > From: Cory D. Wiles [mailto:[EMAIL PROTECTED] > > > Sent: Wednesday, September 12, 2007 2:28 PM > > > To: user@struts.apache.org > > > Subject: Iterate Hashmap with s:iterate > > > > > > I have an action that returns a hash map that I > need > > > to output both the > > > key and value, but I can't figure out how to > access > > > each property with > > > s:iterate. Any suggestions would help. > > > > > > The HashMap is being set in my action and > returned > > > populated (verified > > > with ). > > > > > > // Action snippet > > > Iterator categoryPhysPropsItr = > > > getCategoryPhysProps().iterator(); > > > Map tempMap = new > HashMap(); > > > tempMap = new > > > TreeMap(); > > > > > > while (categoryPhysPropsItr.hasNext()) { > > > DruglistDrugproperty prop = new > > > DruglistDrugproperty(); > > > prop = (DruglistDrugproperty) > > > categoryPhysPropsItr.next(); > > > > > > > > > > > > tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), > > > prop.getDrugService()); > > > > > > } > > > > > > setDrugClassPropsSrvc(tempMap); // HashMap > > > that needs to be > > > iterated through // end Action Snippet > > > > > > // Display JSP > > > > > status="status"> > > > Key ( > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}/>") > > > Value ( > > > > > value="%{drugClassPropsSrvc['+#status.index+'].value}"/>) > > > > > > > > > > > > // end Display JSP > > > > > > Thanks, > > > Cory > > > > > > > > > - > > > To unsubscribe, e-mail: > > > [EMAIL PROTECTED] > > > For additional commands, e-mail: > > > [EMAIL PROTECTED] > > > > > > > > > > > > > - > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Iterate Hashmap with s:iterate
Dave, Where did you find the documentation on the "pseudo-property"? On 9/12/07, Dave Newton <[EMAIL PROTECTED]> wrote: > > IIRC OGNL supplies a pseudo-property "keys" that will > return a list of keys present in the map. > > --- Wesley Wannemacher <[EMAIL PROTECTED]> > wrote: > > > If I remember correctly, to use the s:iterator tag, > > you have to use an > > object that has an 'iterator()' method. HashMap does > > not implement > > java.util.List... > > > > To iterate over a Hashmap, get the keyset > > [tempMap.ketSet()] from it. > > The keyset is a List and you can get an iterator > > from there. > > > > -Wes > > > > -Original Message- > > From: Cory D. Wiles [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, September 12, 2007 2:28 PM > > To: user@struts.apache.org > > Subject: Iterate Hashmap with s:iterate > > > > I have an action that returns a hash map that I need > > to output both the > > key and value, but I can't figure out how to access > > each property with > > s:iterate. Any suggestions would help. > > > > The HashMap is being set in my action and returned > > populated (verified > > with ). > > > > // Action snippet > > Iterator categoryPhysPropsItr = > > getCategoryPhysProps().iterator(); > > Map tempMap = new HashMap(); > > tempMap = new > > TreeMap(); > > > > while (categoryPhysPropsItr.hasNext()) { > > DruglistDrugproperty prop = new > > DruglistDrugproperty(); > > prop = (DruglistDrugproperty) > > categoryPhysPropsItr.next(); > > > > > > > tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), > > prop.getDrugService()); > > > > } > > > > setDrugClassPropsSrvc(tempMap); // HashMap > > that needs to be > > iterated through // end Action Snippet > > > > // Display JSP > > > status="status"> > > Key ( > > value="%{drugClassPropsSrvc['+#status.index+'].value}/>") > > Value ( > > value="%{drugClassPropsSrvc['+#status.index+'].value}"/>) > > > > > > > > // end Display JSP > > > > Thanks, > > Cory > > > > > - > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
RE: Iterate Hashmap with s:iterate
IIRC OGNL supplies a pseudo-property "keys" that will return a list of keys present in the map. --- Wesley Wannemacher <[EMAIL PROTECTED]> wrote: > If I remember correctly, to use the s:iterator tag, > you have to use an > object that has an 'iterator()' method. HashMap does > not implement > java.util.List... > > To iterate over a Hashmap, get the keyset > [tempMap.ketSet()] from it. > The keyset is a List and you can get an iterator > from there. > > -Wes > > -Original Message- > From: Cory D. Wiles [mailto:[EMAIL PROTECTED] > Sent: Wednesday, September 12, 2007 2:28 PM > To: user@struts.apache.org > Subject: Iterate Hashmap with s:iterate > > I have an action that returns a hash map that I need > to output both the > key and value, but I can't figure out how to access > each property with > s:iterate. Any suggestions would help. > > The HashMap is being set in my action and returned > populated (verified > with ). > > // Action snippet > Iterator categoryPhysPropsItr = > getCategoryPhysProps().iterator(); > Map tempMap = new HashMap(); > tempMap = new > TreeMap(); > > while (categoryPhysPropsItr.hasNext()) { > DruglistDrugproperty prop = new > DruglistDrugproperty(); > prop = (DruglistDrugproperty) > categoryPhysPropsItr.next(); > > > tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), > prop.getDrugService()); > > } > > setDrugClassPropsSrvc(tempMap); // HashMap > that needs to be > iterated through // end Action Snippet > > // Display JSP > status="status"> > Key ( value="%{drugClassPropsSrvc['+#status.index+'].value}/>") > Value ( value="%{drugClassPropsSrvc['+#status.index+'].value}"/>) > > > > // end Display JSP > > Thanks, > Cory > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Iterate Hashmap with s:iterate
If I remember correctly, to use the s:iterator tag, you have to use an object that has an 'iterator()' method. HashMap does not implement java.util.List... To iterate over a Hashmap, get the keyset [tempMap.ketSet()] from it. The keyset is a List and you can get an iterator from there. -Wes -Original Message- From: Cory D. Wiles [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 12, 2007 2:28 PM To: user@struts.apache.org Subject: Iterate Hashmap with s:iterate I have an action that returns a hash map that I need to output both the key and value, but I can't figure out how to access each property with s:iterate. Any suggestions would help. The HashMap is being set in my action and returned populated (verified with ). // Action snippet Iterator categoryPhysPropsItr = getCategoryPhysProps().iterator(); Map tempMap = new HashMap(); tempMap = new TreeMap(); while (categoryPhysPropsItr.hasNext()) { DruglistDrugproperty prop = new DruglistDrugproperty(); prop = (DruglistDrugproperty) categoryPhysPropsItr.next(); tempMap.put(prop.getDruglistDrugclass().getDrugClassName(), prop.getDrugService()); } setDrugClassPropsSrvc(tempMap); // HashMap that needs to be iterated through // end Action Snippet // Display JSP Key ( Value () // end Display JSP Thanks, Cory - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]