This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello, any one know of a open source tag library that allows formatting of values. For example, I have 444444444 and I want it formatted as a social security number 444-44-4444. Same with phone numbers, etc. I found the fmt:formatNumber, but it does not work for socials and phone.
If you'd rather avoid scriptlet expressions on the page until you have the opportunity to switch to JSP 2.0 (what's holding that up, by the way?), one technique I've seen used is to use the JSTL to set up a scoped variable and to pass the name of the scoped variable, as opposed to its value, to the custom tag, and then the custom tag fetches the value of the scoped variable using the pageContext.getAttribute() method.
So perhaps something like:
Then, within the tag:
This looks a lot cleaner and creates no artificial binding between the page and the tag (since you pass the name of the variable along rather than hard-coding a name that both sides agree upon -- bad practice).
The only issue I have with this approach is that when JSP 2.0 time comes, refactoring the tag to take the value rather than the name is a bit more work. Of course, this will still work as is under JSP 2.0 -- it just seems a bit of an odd way to do this in that environment.
Joined: Jul 15, 2005
Thanks...I'll try that out. I'd love to switch to JSP 2.0, but we are bound to Sun Java Systems Web Server 6.1, JSP 1.2 and Servlet 2.3