Thursday July 10, 2003
Changing Struts' bean:message to JSTL's fmt:message I converted AppFuse to use JSTL's <fmt:message> tag instead of Struts' <bean:message> tags this morning. It was pretty easy. Here's the steps I took:
1. First, I added the following to metadata/web/seb-settings.xml:
<!-- Define the basename for a resource bundle for I18N -->
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>ApplicationResources</param-value>
</context-param>
2. Then I added the format tag to web/common/taglibs.jsp:
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
3. Finally, I did find/replace with <bean:message/<fmt:message.
4. I also had to change my title and header keys in web/WEB-INF/tiles-config.xml to remove the . from the bean names. In other words, I converted title.key and heading.key to titleKey and headingKey and also made the appropriate changes in web/layouts/baseLayout.jsp.
Easy as Pie! Posted in Java at Jul 10 2003, 07:59:29 AM MDT 31 Comments
Search This Site
Recent Entries
- The Cloud Computing Continuum with Bob McWhirter
- Software Quality: The Quest for the Holy Grail?
- What's Happening in the Java World?
- Fantastic Fun in Jackson Hole
- How We Hired a Team of 10 in 2 Months
- Jack's Skiing Like A Madman!
- My Future of Web Frameworks Presentation
- My Guest Room Remodel is finished!
- Web Application Testing with Selenium by Jason Huggins
- Web Application Testing with Selenium at Agile Denver next Monday
Posted by Kevin on July 10, 2003 at 08:58 AM MDT #
Posted by Matt Raible on July 10, 2003 at 09:39 AM MDT #
Posted by Pratik Patel on July 10, 2003 at 04:48 PM MDT #
1. Future compatibility - it's likely the Struts' tag will be deprecated someday. The JSTL tag is a standard, and most likely here to stay.
2. The other tags that format offers - namely <fmt:formatNumber> and <fmt:formatDate> - both of which are locale-sensitive.
Other than that - just because... ;0)
Posted by Matt Raible on July 10, 2003 at 04:53 PM MDT #
Posted by Dan Allen on July 11, 2003 at 05:16 AM MDT #
Posted by Matt Raible on July 11, 2003 at 05:33 AM MDT #
Posted by Russ on August 10, 2003 at 05:47 AM MDT #
Posted by wunderkind on September 04, 2003 at 09:46 AM MDT #
Posted by minikiller on February 10, 2004 at 06:52 PM MST #
Apparently fmt isn't working properly. Any clue? What am I doing wrong.
Posted by YY on March 25, 2004 at 04:18 PM MST #
Posted by Matt Raible on March 25, 2004 at 04:45 PM MST #
if (lang.equals("RUS")) userLocale=new Locale("ru","RU"); else if (lang.equals("ENG")) userLocale=new Locale("en","US"); else userLocale=getLocale(request); //set user locale setLocale(request,userLocale);But it does not work right now. It always uses ENGLISH. By the way in JWSDP tutorial there is a mistake. They set bundle as<context-param> <param-name> javax.servlet.jsp.jstl.i18n.basename </param-name> <param-value>messages.BookstoreMessages</param-value> </context-param>but name of paramter should be as written above javax.servlet.jsp.jstl.fmt.localizationContextPosted by Stas Sakalou on April 19, 2004 at 09:42 PM MDT #
Posted by Marcel Overdijk on May 05, 2004 at 12:21 PM MDT #
Posted by Tim Chen on June 07, 2004 at 12:19 PM MDT #
Posted by Tim Chen on June 07, 2004 at 12:32 PM MDT #
Posted by Pierre Raoul on September 06, 2004 at 04:59 PM MDT #
Posted by Andrea on March 01, 2005 at 06:52 PM MST #
Posted by 66.46.58.82 on April 01, 2005 at 12:20 PM MST #
Posted by poornima on May 09, 2005 at 05:37 AM MDT #
Posted by 203.123.162.82 on August 03, 2005 at 12:50 AM MDT #
Posted by Prabhakar Thopa on November 30, 2005 at 09:25 AM MST #
I have been using jstl fmt tags to format currency and date values in my jsp code. My colleagues want me to remove this code and move it to the Java presentation logic.
An example: I use fmt:formatNumber value="${myBean.amount}" type="currency"
they want this to change to
c:out value="${myBean.formattedAmount}"
They reason that this makes it more flexible to maintain code, if we decide to have a different view (instead of a jsp) in future. Since the logic for formatting is in java side and not part of the view itself, they say it is easier to maintain and use the same java code to support multiple views.
I am not sure there is a significant advantage as they mention. Would appreciate comments/thoughts on this.
Regards
Prabhakar
Posted by 12.188.33.13 on November 30, 2005 at 09:26 AM MST #
Posted by 193.231.107.60 on January 13, 2006 at 02:06 AM MST #
Please correct your typo :
Change
1. First, I added the following to metadata/web/seb-settings.xml:
to
1. First, I added the following to metadata/web/web-settings.xml:
Yes, the "w" key is just above the "s" key...and for someone as busy as you, you must have typed very fast. :)
Toh Beng Wooi
Malaysia.
Posted by Toh Beng Wooi on September 14, 2006 at 07:56 PM MDT #
Posted by Mayank on December 27, 2006 at 08:11 AM MST #
I need one urgent help. In one of my screen there is autor refresh screen. When I clcick box create by select tag of struts, When I click on select box it should not, screen shuld not reshresh.
How do know, whether my list box is vibike or not.
Regards,
Mayank
Posted by mayank on January 02, 2007 at 07:53 AM MST #
Posted by madhuri on April 12, 2007 at 06:50 AM MDT #
Posted by Bucchi on June 13, 2007 at 01:51 AM MDT #
Posted by Bucchi on June 13, 2007 at 01:51 AM MDT #
Posted by Bucchi on June 13, 2007 at 02:01 AM MDT #
Posted by Cagador sin ley on August 22, 2008 at 10:12 AM MDT #