• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting Java Map entries using JSTL

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am trying to read entries from a Java Map called 'fieldStates' in a JSP. This expression in the JSP:

${fieldStates.uniqueName.valid}

results in the error message: Property 'valid' not found on type controller.FieldState

FieldState is in the controller package and has a public boolean variable called 'valid'. And it is compiled and ready in the \WEB-INF\classes\controller directory.

Am I using the wrong syntax? I have tried some other things, like iterating over the map and printing the object references, but I can't seem to get to the properties.

I use Tomcat 6.0.18 and JSTL 1.1

Thanks



 
Ruben Matthews
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it. The FieldState objects I use in my Map<String, FieldState> didn't have getter and setter methods. Apparently JSTL needs these to access properties of FieldState. It now works.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
removed
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
good catch
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ruben Matthews wrote:I got it. The FieldState objects I use in my Map<String, FieldState> didn't have getter and setter methods. Apparently JSTL needs these to access properties of FieldState. It now works.


Exactly. The EL (not JSTL) operates on Beans. It will only find bean properties. No methods. No fields. Nothing except bean properties.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is true if you are using the standard EL implementation. The JBoss EL goes a bit further on that.

This is an interesting read: http://docs.jboss.org/seam/2.0.2.SP1/reference/en-US/html/elenhancements.html

Similar enhancements are requested on the JSP EL spec according to its issuetracker. We may see it back in future specifications.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As this is the JSP forum, let's not muddy the waters with JBoss-proprietary extensions.
 
Ruben Matthews
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Ruben Matthews wrote:I got it. The FieldState objects I use in my Map<String, FieldState> didn't have getter and setter methods. Apparently JSTL needs these to access properties of FieldState. It now works.


Exactly. The EL (not JSTL) operates on Beans. It will only find bean properties. No methods. No fields. Nothing except bean properties.



Ah, yes, EL. Not JSTL.

It very often happens that I find the solution to an issue while I'm typing or have just typed a forum thread. It forces me to summarize the issue and consider everything I've tried and I often find new things to try while doing this.
 
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic