Re: Localize a dropdown select list
Thank you Jack, that's very kind of you, I will take a look at modifying the taglib this afternoon. --b On Wed, 15 Dec 2004 15:46:09 -0800, Dakota Jack <[EMAIL PROTECTED]> wrote: > Hi, Bryan, > > I could not agree more. But, you might as well bang your head against > the wall as play Cassandra to this version of the Trojan Horse (JSF). > What I do in these cases is to just extend the tags. This one is > fairly easy. Here is a sample early method I built off of which you > can modify with extensions of the Struts tags to suit your taste: > > public List getLocalizedLabelValueList(HttpServletRequest request, > List keys) > throws IOException, > ServletException { >List labelValueList = Collections.synchronizedList(new > LinkedList()); >HttpSession session= request.getSession(); >Locale locale = > (Locale)session.getAttribute(Globals.LOCALE_KEY); >Iterator iterator = keys.iterator(); >MessageResources messages = this.getResources(request); > >while(iterator.hasNext()) { > String value = ((String)iterator.next()); > String label = convertToUTF8(messages.getMessage(locale,value)); > labelValueList.add(new LabelValueBean(label,value)); >} > >return labelValueList; > } > > Jack > > > On Wed, 15 Dec 2004 10:59:37 +0100, bryan <[EMAIL PROTECTED]> wrote: > > If I were to speculate which would be more usefull to the community, > > implementing something basic like this or creating support for JSF I > > would imagine that this would > > probably be more useful. > > > > This reminds me of my skateboarding days, before learning how to do a > > 360 fakie kickflip it's kinda usefull to learn how to do an ollie > > > > Thanks Niall. > > > > --b > > > > On Wed, 15 Dec 2004 00:24:11 -, Niall Pemberton > > <[EMAIL PROTECTED]> wrote: > > > It has come up before: > > > > > > http://issues.apache.org/bugzilla/show_bug.cgi?id=9748 > > > http://issues.apache.org/bugzilla/show_bug.cgi?id=17600 > > > > > > but it hasn't been implemented in Struts > > > > > > Niall > > > > > > - Original Message - > > > From: "bryan" <[EMAIL PROTECTED]> > > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > > Sent: Tuesday, December 14, 2004 8:10 PM > > > Subject: Localize a dropdown select list > > > > > > > Is this possible with struts ? i don't find a mention of it but can't > > > > imagine it hasn't been implemented. > > > > > > > > For example in the jsp > > > > > > > > > > > > > > > value="name" label="name"/> > > > > > > > > > > > > Which generates the following ... > > > > > > > value="type.yes">type.yes > > > > type.no > > > > type.option_to_build > > > > type.undefined > > > > > > > > Is it possible to map type.no to a value in the resource bundles ?? > > > > > > > > --b > > > > > > > > -- > > > > http://www.revoltingdigits.com > > > > https://jestate.dev.java.net > > > > > > > > - > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > -- > > http://www.revoltingdigits.com > > https://jestate.dev.java.net > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > "You can lead a horse to water but you cannot make it float on its back." > > ~Dakota Jack~ > > "You can't wake a person who is pretending to be asleep." > > ~Native Proverb~ > > "Each man is good in His sight. It is not necessary for eagles to be crows." > > ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ > -- http://www.revoltingdigits.com https://jestate.dev.java.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Localize a dropdown select list
Sorry, Bryan, here's the rest: protected String convertToUTF8(String original) { try { byte[] utf8Bytes = original.getBytes("UTF8); original = new String(utf8Bytes,"UTF8"); } catch (UnsupportedEncodingException uee) { // logging, etc. } return original; } Jack On Wed, 15 Dec 2004 10:59:37 +0100, bryan <[EMAIL PROTECTED]> wrote: > If I were to speculate which would be more usefull to the community, > implementing something basic like this or creating support for JSF I > would imagine that this would > probably be more useful. > > This reminds me of my skateboarding days, before learning how to do a > 360 fakie kickflip it's kinda usefull to learn how to do an ollie > > Thanks Niall. > > --b > > On Wed, 15 Dec 2004 00:24:11 -, Niall Pemberton > <[EMAIL PROTECTED]> wrote: > > It has come up before: > > > > http://issues.apache.org/bugzilla/show_bug.cgi?id=9748 > > http://issues.apache.org/bugzilla/show_bug.cgi?id=17600 > > > > but it hasn't been implemented in Struts > > > > Niall > > > > - Original Message - > > From: "bryan" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > Sent: Tuesday, December 14, 2004 8:10 PM > > Subject: Localize a dropdown select list > > > > > Is this possible with struts ? i don't find a mention of it but can't > > > imagine it hasn't been implemented. > > > > > > For example in the jsp > > > > > > > > > > > value="name" label="name"/> > > > > > > > > > Which generates the following ... > > > type.yes > > > type.no > > > type.option_to_build > > > type.undefined > > > > > > Is it possible to map type.no to a value in the resource bundles ?? > > > > > > --b > > > > > > -- > > > http://www.revoltingdigits.com > > > https://jestate.dev.java.net > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > http://www.revoltingdigits.com > https://jestate.dev.java.net > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- "You can lead a horse to water but you cannot make it float on its back." ~Dakota Jack~ "You can't wake a person who is pretending to be asleep." ~Native Proverb~ "Each man is good in His sight. It is not necessary for eagles to be crows." ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Localize a dropdown select list
Hi, Bryan, I could not agree more. But, you might as well bang your head against the wall as play Cassandra to this version of the Trojan Horse (JSF). What I do in these cases is to just extend the tags. This one is fairly easy. Here is a sample early method I built off of which you can modify with extensions of the Struts tags to suit your taste: public List getLocalizedLabelValueList(HttpServletRequest request, List keys) throws IOException, ServletException { List labelValueList = Collections.synchronizedList(new LinkedList()); HttpSession session= request.getSession(); Locale locale = (Locale)session.getAttribute(Globals.LOCALE_KEY); Iterator iterator = keys.iterator(); MessageResources messages = this.getResources(request); while(iterator.hasNext()) { String value = ((String)iterator.next()); String label = convertToUTF8(messages.getMessage(locale,value)); labelValueList.add(new LabelValueBean(label,value)); } return labelValueList; } Jack On Wed, 15 Dec 2004 10:59:37 +0100, bryan <[EMAIL PROTECTED]> wrote: > If I were to speculate which would be more usefull to the community, > implementing something basic like this or creating support for JSF I > would imagine that this would > probably be more useful. > > This reminds me of my skateboarding days, before learning how to do a > 360 fakie kickflip it's kinda usefull to learn how to do an ollie > > Thanks Niall. > > --b > > On Wed, 15 Dec 2004 00:24:11 -, Niall Pemberton > <[EMAIL PROTECTED]> wrote: > > It has come up before: > > > > http://issues.apache.org/bugzilla/show_bug.cgi?id=9748 > > http://issues.apache.org/bugzilla/show_bug.cgi?id=17600 > > > > but it hasn't been implemented in Struts > > > > Niall > > > > - Original Message - > > From: "bryan" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > Sent: Tuesday, December 14, 2004 8:10 PM > > Subject: Localize a dropdown select list > > > > > Is this possible with struts ? i don't find a mention of it but can't > > > imagine it hasn't been implemented. > > > > > > For example in the jsp > > > > > > > > > > > value="name" label="name"/> > > > > > > > > > Which generates the following ... > > > type.yes > > > type.no > > > type.option_to_build > > > type.undefined > > > > > > Is it possible to map type.no to a value in the resource bundles ?? > > > > > > --b > > > > > > -- > > > http://www.revoltingdigits.com > > > https://jestate.dev.java.net > > > > > > - > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > -- > http://www.revoltingdigits.com > https://jestate.dev.java.net > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- "You can lead a horse to water but you cannot make it float on its back." ~Dakota Jack~ "You can't wake a person who is pretending to be asleep." ~Native Proverb~ "Each man is good in His sight. It is not necessary for eagles to be crows." ~Hunkesni (Sitting Bull), Hunkpapa Sioux~ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Localize a dropdown select list
If I were to speculate which would be more usefull to the community, implementing something basic like this or creating support for JSF I would imagine that this would probably be more useful. This reminds me of my skateboarding days, before learning how to do a 360 fakie kickflip it's kinda usefull to learn how to do an ollie Thanks Niall. --b On Wed, 15 Dec 2004 00:24:11 -, Niall Pemberton <[EMAIL PROTECTED]> wrote: > It has come up before: > > http://issues.apache.org/bugzilla/show_bug.cgi?id=9748 > http://issues.apache.org/bugzilla/show_bug.cgi?id=17600 > > but it hasn't been implemented in Struts > > Niall > > - Original Message - > From: "bryan" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > Sent: Tuesday, December 14, 2004 8:10 PM > Subject: Localize a dropdown select list > > > Is this possible with struts ? i don't find a mention of it but can't > > imagine it hasn't been implemented. > > > > For example in the jsp > > > > > > > value="name" label="name"/> > > > > > > Which generates the following ... > > type.yes > > type.no > > type.option_to_build > > type.undefined > > > > Is it possible to map type.no to a value in the resource bundles ?? > > > > --b > > > > -- > > http://www.revoltingdigits.com > > https://jestate.dev.java.net > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- http://www.revoltingdigits.com https://jestate.dev.java.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Localize a dropdown select list
Bryan, Here's some thoughts: - Leverage the Java language's inherent ability to internationalize things. - Leverage commons-resources to internationalize things. - Use a database to internationalize things. They aren't necessarily mutually-exclusive options, although there's little reason to use the first if you're using the second. The third can be a very powerful option, if you build your database in such a way that it allows you to store your text in different languages. Put a dozen programmers in a room and you'll come up with 20 different ways to do that - all of them better than the other, depending upon the requirements at hand. I'll leave determining a method as an exercise to you. What I'm trying to say, and probably doing an exceedingly poor job of is that the view really should just display data. Your model, invoked through your actions, should determine the apropriate data to hand over to the view. Beyond that, it's really moot how you do it. My personal tendency is to use some sort of resource bundle, commons-resources or other, to handle the "static" items, and to handle a database for dynamic ones. Google "Java i18n", "Java internationalization", or visit jakarta.apache.org/commons/resources for the static approaches. Good Luck! Eddie - Original Message - From: "bryan" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, December 14, 2004 2:10 PM Subject: Localize a dropdown select list Is this possible with struts ? i don't find a mention of it but can't imagine it hasn't been implemented. For example in the jsp Which generates the following ... type.yes type.no type.option_to_build type.undefined Is it possible to map type.no to a value in the resource bundles ?? --b -- http://www.revoltingdigits.com https://jestate.dev.java.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0451-1, 12/14/2004 Tested on: 12/14/2004 10:40:25 PM avast! - copyright (c) 2000-2004 ALWIL Software. http://www.avast.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Localize a dropdown select list
It has come up before: http://issues.apache.org/bugzilla/show_bug.cgi?id=9748 http://issues.apache.org/bugzilla/show_bug.cgi?id=17600 but it hasn't been implemented in Struts Niall - Original Message - From: "bryan" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, December 14, 2004 8:10 PM Subject: Localize a dropdown select list > Is this possible with struts ? i don't find a mention of it but can't > imagine it hasn't been implemented. > > For example in the jsp > > > value="name" label="name"/> > > > Which generates the following ... > type.yes > type.no > type.option_to_build > type.undefined > > Is it possible to map type.no to a value in the resource bundles ?? > > --b > > -- > http://www.revoltingdigits.com > https://jestate.dev.java.net > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Localize a dropdown select list
Is this possible with struts ? i don't find a mention of it but can't imagine it hasn't been implemented. For example in the jsp Which generates the following ... type.yes type.no type.option_to_build type.undefined Is it possible to map type.no to a value in the resource bundles ?? --b -- http://www.revoltingdigits.com https://jestate.dev.java.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]