Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13083

Re: JSTL: getting a map's keys

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: JSTL: getting a map's keys
Date Tue, 20 Mar 2012 11:05:14 -0700 (PDT)
Organization http://groups.google.com
Lines 47
Message-ID <14359232.4616.1332266714833.JavaMail.geo-discussion-forums@pbcr5> (permalink)
References <9spbepF1baU1@mid.individual.net> <xLP9r.4373$dq4.2106@newsfe23.iad> <9srshfFjo5U1@mid.individual.net> <9sruffF39oU1@mid.individual.net>
NNTP-Posting-Host 69.28.149.29
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Trace posting.google.com 1332266715 20622 127.0.0.1 (20 Mar 2012 18:05:15 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Tue, 20 Mar 2012 18:05:15 +0000 (UTC)
In-Reply-To <9sruffF39oU1@mid.individual.net>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
User-Agent G2/1.0
X-Received-Bytes 2833
Xref csiph.com comp.lang.java.programmer:13083

Show key headers only | View raw


Chris Riesbeck wrote:
> Chris Riesbeck wrote:
>> Daniel Pitts wrote:
>>> Chris Riesbeck wrote:
>>>>
>>>> [summary: rates is an instance of a subclass of Map that
>>>>  implements getKeys()]
>>>>
>>>> Why does ${rates.keys} generate nothing in these lines of JSP?
>>>>
>>> My guess is that ${rates.keys} is interpreted as equivalent to
>>> ${rates['keys']}, so it is looking for a key of "keys", not a java bean
>>> property.
> 
> Just to nail the coffin lid shut on this. The JSP EL defines name.key as 
> just shorthand for name["key"]. To interpret [] expressions, JSP uses 
> the first answer it gets from this chain of resolvers:
> 
>      ImplicitObjectELResolver
>      registered custom ELResolvers
>      MapELResolver
>      ListELResolver
>      ArrayELResolver
>      BeanELResolver
>      ScopedAttributeELResolver
> 
>  
> http://docs.oracle.com/javaee/5/api/javax/servlet/jsp/JspApplicationContext.html
> 
> So the Map interpretation will always override the Bean interpretation.

Now that your main question is answered, a couple of comments are in order.

- Don't have scriptlet in your JSPs.
- If you had *composed* a 'Map' into a custom class rather than inheriting 'Map', you would not have had the problem. Your custom class would have been resolved by the bean resolver.
- This in turn would make for a better design overall. Instead of your view artifact (the JSP) caring about the implementation details of the map and its set of keys, you'd have a controller call like 'getKeys()' or whatever that would cleanly separate the logic of how you get them from presentation concerns.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-19 13:15 -0500
  Re: JSTL: getting a map's keys Lew <lewbloch@gmail.com> - 2012-03-19 12:57 -0700
  Re: JSTL: getting a map's keys Tim Slattery <Slattery_T@bls.gov> - 2012-03-19 16:08 -0400
    Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-19 16:06 -0500
      Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-19 16:39 -0500
    Re: JSTL: getting a map's keys markspace <-@.> - 2012-03-19 15:27 -0700
  Re: JSTL: getting a map's keys Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-19 16:59 -0700
    Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-20 12:19 -0500
      Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-20 12:52 -0500
        Re: JSTL: getting a map's keys Lew <lewbloch@gmail.com> - 2012-03-20 11:05 -0700
          Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-21 13:09 -0500
            Re: JSTL: getting a map's keys Lew <noone@lewscanon.com> - 2012-03-22 07:51 -0700
              Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-22 12:53 -0500
                Re: JSTL: getting a map's keys Lew <lewbloch@gmail.com> - 2012-03-22 13:23 -0700
                Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-23 12:23 -0500
                Re: JSTL: getting a map's keys Lew <noone@lewscanon.com> - 2012-03-23 13:50 -0700
                Re: JSTL: getting a map's keys Chris Riesbeck <Chris.Riesbeck@gmail.com> - 2012-03-26 14:10 -0500
        Re: JSTL: getting a map's keys Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-20 11:28 -0700
        Re: JSTL: getting a map's keys markspace <-@.> - 2012-03-20 11:29 -0700
          Re: JSTL: getting a map's keys Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-03-20 12:10 -0700

csiph-web