aspose file tools*
The moose likes JSP and the fly likes EL not being evaluated before passing as parameter to custom tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "EL not being evaluated before passing as parameter to custom tag" Watch "EL not being evaluated before passing as parameter to custom tag" New topic
Author

EL not being evaluated before passing as parameter to custom tag

Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
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 ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

In your TLD, what did you set the "number" attribute to ? "rtexprvalue" ?


[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61241
    
  66

And is this in a JSP 2.0 web app?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61241
    
  66

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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61241
    
  66

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,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL not being evaluated before passing as parameter to custom tag