aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes fmt: tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "fmt: tag " Watch "fmt: tag " New topic
Author

fmt: tag

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Hi,
Now that i have cleared SCWCD i want to apply that knowledge to my job and in this process i want to use i18N support available in the JSTL library via fmt tag.

I was able to successfully get locale specific strings via
<fmt:bundle basename="TempMgrResources">
<fmt:setLocale value="${loginBean.locale}"/>
<fmt:message key="Report.StepText" />
</fmt:bundle>

But now to access every key in the resource bundle do i have to repeat the above three lines every where. Is there no way to
a) Set the Resource bundle
b) set the locale

After doing these two just access the keys via fmt:message tag.


SCJP, SCWCD, SCBCD
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Answer:
<fmt:setBundle basename="TempMgrResources" var="resource"/>

The above code will store the Resource bundle into the resource specified by the var attribute of setBundle tag, scoped variable which can be used in the rest of the JSP's as follows


<fmt:message key="Report.StepText" bundle="${resource}"/>

Looks cool .
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
The thing that i did not understand was how did the locale got set automatically???
Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637
Locale does get set automatically to browser locale using ServletRequest.getLocales() which can be overridden by <fmt:setLocale/>.

This thread can now be closed
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fmt: tag