• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing variable name to java method with JSTL

 
Riccardo Panaia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All, my first time posting here. I've done some research on this topic and so far have come up empty. What I am trying to do is call a java method and pass a parameter string using JSTL. Here is a sample of the code I am using:
<c:when test='${holding.product.validity["lineOfBusiness"] == "1"}'> This code compiles but throws this error when hit:
An error occurred while evaluating custom action attribute "test" with value "${holding.product.validity["lineOfBusiness"] == "1" && holding.product.lineOfBusiness != null}":
Unable to find a value for "validity" in object of class "com.mm.dts.paar.data.PAARProduct" using operator "." (null)
Now I am fairly new to the whole java/jsp/jstl realm, but my first question is it possible to call a java method and pass in a parameter using jstl core tags? If this it true, then my next question would be is my syntax messed up that's causing it to fail? Thanks in advance for any suggestions/comments. Thanks, Rick.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To my knowledge, no. (Caveat, I recall reading something about JSP 2 being able to do something along these lines, but I haven't had a chance to play around with it yet -- you know, busy getting product out the door and all).
However, in your example, the EL is expecting 'validity' to be a property of the 'product' bean. If 'validity' is a method (as I suspect from your post), the EL will not call it. (Rather it is looking for method getValidity()).
bear
 
Riccardo Panaia
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the input Bear, I was afraid of that. Back to rewriting my code. Happy New Year!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic