• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

EL not being evaluated before passing as parameter to custom tag

 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a custom tag to take in a number (stored as a String) and output a dash if it's blank, or otherwise the input gets displayed. Here's an example of the tag in use on a JSP:




The problem is that the EL is not being evaluated before being passed back to the tag handler. Aside from doEndTag where results is simply written out, everything is done in my DisplayValue class's doStartTag method:




In that class, number is set to ${myObject.contractDto.priorityRank} and of course I would like for that to be evaluated before I check to see if it's empty! I've also tried this:




I downloaded the Jakarta Taglibs source to get a look at FormatDateTag.java, and here's an example of how we use it in one of our JSPs:



For some reason, ${myObject.inceptionDate} gets evaluated correctly and I can't see how that's done in FormatDateTag.java, FormatDateTagSupport.java, or FormatTagSupport.java! I probably just need to go home and sleep. ;)


DisplayTag extends BodyTagSupport, so I'd assume it would have picked up any magic properties that those FormatDateTag-related classes would have that would make sure EL gets evaluated before being used in the tag handling methods. Any ideas?
[ June 14, 2007: Message edited by: Stephen Huey ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your TLD, what did you set the "number" attribute to ? "rtexprvalue" ?
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And is this in a JSP 2.0 web app?
 
Stephen Huey
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP 2.0 with JSTL 1.0.6, and I did set rtexprvalue to true. I found out here that I needed to use ExpressionEvaluatorManager's evaluate method in my tag class.

 
Bear Bibeault
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

JSP 2.0 with JSTL 1.0.6



Incompatible. You should be using JSTL 1.1.

And if your web app is configured correctly you will not need to anything special in your own tags,
 
Bear Bibeault
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I found out here that I needed to use ExpressionEvaluatorManager's evaluate method in my tag class.



You only need to do this because your web app is incorrectly configured.

Under JSP 2.0, the JSP engine will translated the EL expression prior to invoking the tag,
 
If you're gonna buy things, buy this thing and I get a fat kickback:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!