Test class:
--------------
public class HashWrapper implements java.io.Serializable {
java.util.HashMap map = new java.util.HashMap();
public HashWrapper() {
map.put("item1", "H");
map.put("item2", "E");
map.put("item3", "I");
}
public String getItem(String item){
return (String)map.get(item);
}
}
----------------
request setAttribute("hashWrapper",new HashWrapper());
------------------
Then I used the syntax for the tags:
<logic:equal name="hashWrapper" property="item(item2)" value
="H"></logic:equal>
[EMAIL PROTECTED] on 08/27/2002 11:44:02 AM
Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
cc:
Subject: RE: Hashmap and logic:equal
"I think with Hashmap you just need key or value, so where you have
property="mapkey1" change to key or value"
I am a bit confused ,I will clarify..
Aa an eample, in my loadAction:
Map myMap = new Map();
myMap.put("item1","X");
myMap.put("item2","Y");
request.setAttrite("infoObject",myMap);
In my Page:
<logic:equals name="infoObject" property="item1????" value="X > Show A
</logic:equals>
Can this even by done? I was hoping not to have to use a scriptlet or
iterate.
Thanks
Darryl Nortje <[EMAIL PROTECTED]> on 08/27/2002 11:18:50 AM
Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
cc:
Subject: RE: Hashmap and logic:equal
This is how I got it of my form object
<logic:equal name="defaultForm" property="jspAction" scope="request"
value="indexDoc">
and this is how I got it out of a collection object
<logic:iterate name="attrib" id="collElem">
<logic:equal name="collElem" property="isReadonly" value="readonly">
In the form object I have a getJspAction() method and in the collection
object I have a getIsReadonly() method.
I think with Hashmap you just need key or value, so where you have
property="mapkey1" change to key or value
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 27, 2002 6:10 PM
To: [EMAIL PROTECTED]
Subject: Hashmap and logic:equal
I am hoping that someone could point me in the right direction.
I have been searching the archives and have not come accross anything that
I can relate to.
Using the equal tags, what is the best way to compare a value retieved from
a Hashmap?
I would like to put a Hashmap (or similar) into request scope and use the
logic:equals tag. and do something like this.
<logic:equals name="mapName" property="mapkey1" value="<%= Constant.value
%>" > Show A </logic:equals>
<logic:equals name="mapName" property="mapkey2" value="<%= Constant.value
%>" > Show B </logic:equals>
<logic:equals name="mapName" property="mapkey3" value="<%= Constant.value
%>" > Show C </logic:equals>
Do I need to wrap this in simple class?
The docs make reference to the support of indexed properties, is there a
way to get the tag to look up the name of the key?
Thanks All
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>