I have done something similar (I think).
Let me understand exactly what you are doing...
you have a LinkedHashMap called masterMap, which holds a collection of MyTO objects. These objects also contain a HashMap which you want to iterate over? If that is correct you can try the following:
1) retrieve the masterMap from the request.
2) retrieve the set of keys from masterMap using masterMap.keySet();
3) iterate through the keys retrieving the myTO object.
4) for each myTO object, retrieve the HashMap.
5) again, use the keySet method of HashMap to get a Set of the keys.
6) iterate through the keys to retrieve the values/object associated.
example code:
LinkedHashMap<String, myTO> masterMap = (LinkedHashMap<String, myTo>)request.getAttribute(
Set<String> keysForMasterMap = masterMap.keySet();
Iterator<String> keysIterator = keysForMasterMap.iterator(
while(keysIterator.hasNext
String key = keysIterator.next();
MyTO myTO = masterMap.get(key);
HashMap<String, XXXX> mapFromMyTO = myTO.getXXXX();
Set<String> keysFromMyTOMap = mapFromMyTO.keySet();
Iterator<String> myTOMapKeysIterator = keysFromMyTOMap.iterator()
while(myTOMapKeysIterator.
String keyForObject = myTOMapKeysIterator.next()
ObjectXXXX objectRetrieved = mapFromMyTO.get(keyForObje
//Now you can do something with the object you have retrieved.
}
}
Main Topics
Browse All Topics





by: objectsPosted on 2009-02-08 at 14:40:48ID: 23586118
sounds like you need the key, otherwise how can you access the map