Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

Passing locale object to JSP Custom Tags

Thread view: 
kitty - 26 Mar 2007 11:37 GMT
Hi,

I have created a custom tag for passing date and locale objects and
getting the locale specific date.
I need to pass the locale and date objects from my form bean to the
tag but i should not use scriptlets, the requirement states that using
scriptlets is bad practise.

My JSP code,

<%@ taglib uri="/WEB-INF/Customi18n.tld" prefix="i18n" %>
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%
    Locale newlocale = new Locale("en","GB");
    Date date1 = new Date();
    int dateFormat = java.text.DateFormat.LONG;
%>
Localized Date : <i18n:date locale="<%= newlocale %>" inputdate="<%=
date1 %>" dateFormat="<%= dateFormat %>" />

Please let me know if there is any other way to pass the locale and
date object to the tag. Thanks in advance for all the help.

Regards,
Kitty
Lew - 26 Mar 2007 12:59 GMT
> Hi,
>
[quoted text clipped - 20 lines]
> Please let me know if there is any other way to pass the locale and
> date object to the tag. Thanks in advance for all the help.

Why not just pass the locale strings ("en", "GB") to the tag implementation
and let the tag create the Locale and Date (or Calendar) objects?

Then all that nasty scriptlet leaves the JSP.

-- Lew
Doug - 26 Mar 2007 15:50 GMT
> Hi,
>
[quoted text clipped - 23 lines]
> Regards,
> Kitty

Hello,
I suggest you to look at the JSTL library.
It has all formatting functionalities that you are loking for instead
of trying to re-invent the wheel buddy.

Regards,

Doug


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.