wood burning stoves 2.0*
The moose likes JSP and the fly likes **SOLVED** tag handler outputting localised text - how to do this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "**SOLVED** tag handler outputting localised text - how to do this?" Watch "**SOLVED** tag handler outputting localised text - how to do this?" New topic
Author

**SOLVED** tag handler outputting localised text - how to do this?

Edward Winchester
Ranch Hand

Joined: Sep 16, 2009
Posts: 65
Hello,

Solved (see bottom of message).

Been trying to find out how to output localised text from my tag handler. My handler extends SimpleTagSupport. This is the road I've gone down: After some searching I found the class LocaleSupport which says:

This class may be useful to any tag handler implementation that needs to produce localized messages. For example, this might be useful for exception messages that are intended directly for user consumption on an error page.

Sounds ideal! However all 4 methods of LocaleSupport require a javax.servlet.jsp.PageContext as their first parameter. I can't find out how to get an instance of this type. calling getJspContext() in my tag handler gives me a JspContext which is a superclass of PageContext.

Hope someone can help me with this! Perhaps there's a more direct, better way?

Thanks,

Ed


Solution:
Rather than extending from SimpleTagSupport, I extended my tag handler from BodyTagSupport. I could still specify (in the TLD file) that the handler expects an empty body. Subclasses of BodyTagSupport get access to the pageContext variable which is exactly what needs to be supplied as the first parameter to the LocaleSupport methods.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: **SOLVED** tag handler outputting localised text - how to do this?
 
Similar Threads
Custom Tags_ SimpleTagSupport
Custom tag handler, the usage of doTag() method.
Tutorial on Dynamic Attributes
Which one to select between Classic custom tag and Simple custom tag
Doubt on findAncestorWithClass(Tag form,java.lang.Class klass)