• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Java Map entries using JSTL

 
Ruben Matthews
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Duc Vo
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
removed
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good catch
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic