You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by eugene neymark <en...@keymage.com> on 2002/03/06 19:40:41 UTC
Accessing values in hashMap through key with struts
Hi!
Any clues to how to access HashMap through a key with struts?
Strut documentation is very vague on this subject.
here a sample of what i tried and it doesn't werk even though it compiles...
<bean:define id="hashOfUsers" name="prepareUsersForRoleForm"
property="usersWithRoles" type="java.util.HashMap"/>
<bean:define id="arrayOfRoles" name="hashOfUsers" property="[<%="" +
userId.intValue() %>]" type="java.util.ArrayList"/>
so the above compiles but whn i try to iterate the 'arrayOfRoles' it says
that there is no collection. strangely enough there is no collection as i
can not even access the 'arrayOfRoles' through the scriplet.
here's what i do instead and it worx but i want it to be purely in struts..
<iterate id='user'........>
<% int id = ((User)user).getId();
roles = (ArrayList)((HashMap)hashOfUsers).get("" + id);
for(int i = 0; i < roles.size(); i++){
%>
<%=((Role)roles.get(i)).getName()%>
<%}%>
</iterate>
Thanks !
Eugene
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>