Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Chris Riesbeck Newsgroups: comp.lang.java.programmer Subject: Re: JSTL: getting a map's keys Date: Fri, 23 Mar 2012 12:23:32 -0500 Lines: 25 Message-ID: <9t3pslFi0vU1@mid.individual.net> References: <9spbepF1baU1@mid.individual.net> <9srshfFjo5U1@mid.individual.net> <9sruffF39oU1@mid.individual.net> <14359232.4616.1332266714833.JavaMail.geo-discussion-forums@pbcr5> <9sujq2Foc1U1@mid.individual.net> <9t1791Fdo5U1@mid.individual.net> <11405563.61.1332447814183.JavaMail.geo-discussion-forums@pbctp7> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 1VpxEi7QSbn1ZZMJcvkcoAphw3bu/3XiM0iciclSgVJKCOs7YM Cancel-Lock: sha1:JPYYjnCpvzVbn9QMJ9V1GTlbkHU= User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120312 Thunderbird/11.0 In-Reply-To: <11405563.61.1332447814183.JavaMail.geo-discussion-forums@pbctp7> Xref: csiph.com comp.lang.java.programmer:13136 On 3/22/2012 3:23 PM, 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 rates = howeverYouSetItUp(); > public Map getRates() { return Collections.unmodifiableMap(rates); } > public Set 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. Thanks, all.