You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Hertz <jh...@speakeasy.net> on 2005/08/12 01:29:47 UTC
Locale Aware Form Objects?
It seems logical to do, but steadfastly avoided. So I'm wondering if this is
a bad idea or not-
Example:
You have a series of i18N'd CRUD screens. On one of them, you allow the user
to retrieve some data, edit it, and save it back.
On this type of screen, it really makes life easier if you pass the data
into the screen on an instance of the FormBean that is going to be submitted
back to you. The JSP properties will display it as is.
This has gotten me in the habit of using FormBeans for display purposes.
So now I'm thinking, why not add i18N functionality into the FormBean? It
seems to me to be a pretty good place to do it.
If a field contains a code, you can copy that into the form into the
"widgetCode" property, confident that the getter for "widgetText" will
convert it for you to the right language.
But to do this, you need an ActionForm Object that can store a Locale and a
MessageResources bundle.
Is there any reason not to? (Form Scoping issues? etc)
TIA
-Joe
Re: Locale Aware Form Objects?
Posted by Dakota Jack <da...@gmail.com>.
I know how you edit. How do you edit an i18n file? That is something
that is a bit of a mystery to me. Don't you see the problem? Imagine
doing it.
On 8/15/05, Laurie Harper <la...@holoweb.net> wrote:
> Dakota Jack wrote:
> > On 8/14/05, Laurie Harper <la...@holoweb.net> wrote:
> > [Jack: he's not talking about
> >>localizing natural language data entered by the user, that's clearly not
> >>feasible!]
> >
> > Fair enough! Out of curiosity, how do you "edit" the data without
> > "natural language"?
>
> Same as with any other fixed static data I would guess: using a select box,
> radio button group, etc. Unless I completely mis-understood what Joe was
> talking about :-)
>
> L.
> --
> Laurie Harper
> Open Source advocate, Java geek: http://www.holoweb.net/laurie
> Founder, Zotech Software: http://www.zotechsoftware.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Locale Aware Form Objects?
Posted by Laurie Harper <la...@holoweb.net>.
Dakota Jack wrote:
> On 8/14/05, Laurie Harper <la...@holoweb.net> wrote:
> [Jack: he's not talking about
>>localizing natural language data entered by the user, that's clearly not
>>feasible!]
>
> Fair enough! Out of curiosity, how do you "edit" the data without
> "natural language"?
Same as with any other fixed static data I would guess: using a select box,
radio button group, etc. Unless I completely mis-understood what Joe was
talking about :-)
L.
--
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Locale Aware Form Objects?
Posted by Dakota Jack <da...@gmail.com>.
On 8/14/05, Laurie Harper <la...@holoweb.net> wrote:
[Jack: he's not talking about
> localizing natural language data entered by the user, that's clearly not
> feasible!]
Fair enough! Out of curiosity, how do you "edit" the data without
"natural language"?
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Locale Aware Form Objects?
Posted by Laurie Harper <la...@holoweb.net>.
So you want to take static model data (e.g. a product type code) and,
instead of looking up a localized display name for that type code in the
JSP, do the lookup in the action form? [Jack: he's not talking about
localizing natural language data entered by the user, that's clearly not
feasible!]
You certainly could do that. You'd have to pass the appropriate locale into
the form bean in the action you use to pre-populate data for the JSP or at
the start of the JSP itself. The trade off is slightly simpler JSP markup
(e.g. <bean:write value="myForm.productTypeDisplayText"/> instead of
<bean:message key="myForm.productType" fmt="..."/> vs. a loss of
flexibility. For example, if you wanted to tweak the display format, you'd
have to recompile your form bean rather than just edit the JSP.
On the other hand, your form bean and/or action already needs to be
locale-aware when parsing data entered by the user (think about entering
dates, for example: you have to know how to parse the date string according
to the user's locale). Whilst you can control locale specific formatting of
output data in the JSP, there's no way to do so for input data. So keeping
both in the same place (e.g. the form bean) is probably a good idea.
I'd probably make sure the option was there to override formatting in the
JSP just in case (e.g. by having both getProductType() and
getProductTypeDisplayText() on the form bean), though. And I may not bother
for uni-directional data (i.e. data that only needs to be localized for
display, with no locale-to-canonical-representation processing in the other
direction). So for the product code example I probably wouldn't put
localization code in the action form, but I would for something like an
editable date property.
L.
Joe Hertz wrote:
> It seems logical to do, but steadfastly avoided. So I'm wondering if this is
> a bad idea or not-
>
>
>
> Example:
>
>
>
> You have a series of i18N'd CRUD screens. On one of them, you allow the user
> to retrieve some data, edit it, and save it back.
>
>
>
> On this type of screen, it really makes life easier if you pass the data
> into the screen on an instance of the FormBean that is going to be submitted
> back to you. The JSP properties will display it as is.
>
>
>
> This has gotten me in the habit of using FormBeans for display purposes.
>
>
>
> So now I'm thinking, why not add i18N functionality into the FormBean? It
> seems to me to be a pretty good place to do it.
>
>
>
> If a field contains a code, you can copy that into the form into the
> "widgetCode" property, confident that the getter for "widgetText" will
> convert it for you to the right language.
>
>
>
> But to do this, you need an ActionForm Object that can store a Locale and a
> MessageResources bundle.
>
>
>
> Is there any reason not to? (Form Scoping issues? etc)
>
>
>
> TIA
>
>
>
> -Joe
>
>
--
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Locale Aware Form Objects?
Posted by Dakota Jack <da...@gmail.com>.
This does not make sense to me. If the person is editing the data, as
the questioner said, how is that going to be i18n-ed? To do that you
would have to convert the submitted data on the fly to the languages.
Either I don't understand what you guys are saying or it makes no
sense.
On 8/14/05, Eddie Bush <ea...@swbell.net> wrote:
> Hi Joe,
>
> I'm not sure I understand your question, but ...
>
> Here's what I do:
> I use form beans to tote data around. My labels, OTOH, are externalized and
> use bundles to achieve i18n, and this is all fairly transparent on the page.
>
> Here's what I think you want to do:
> If I understand you correctly, you want to apply i18n to data the same way
> that is commonly done to labels.
>
> I don't like the idea of applying i18n data at the form-level, since that
> would require the form to make requests of the model. Rather, my approach
> is to have a model with built-in i18n, where I then determine the locale and
> translate that to a code that I hand the model when requesting data.
> Consequently, I retrieve the data for the proper locale and populate the
> form -- lots cleaner, I think.
>
> Is that clear as mud? Did I even understand your question?
>
> Hope so!
>
> Eddie
>
> ----- Original Message -----
> From: "Joe Hertz" <jh...@speakeasy.net>
> To: "'Struts Users Mailing List'" <us...@struts.apache.org>
> Sent: Thursday, August 11, 2005 6:29 PM
> Subject: Locale Aware Form Objects?
>
>
> > It seems logical to do, but steadfastly avoided. So I'm wondering if this
> > is
> > a bad idea or not-
> >
> >
> >
> > Example:
> >
> >
> >
> > You have a series of i18N'd CRUD screens. On one of them, you allow the
> > user
> > to retrieve some data, edit it, and save it back.
> >
> >
> >
> > On this type of screen, it really makes life easier if you pass the data
> > into the screen on an instance of the FormBean that is going to be
> > submitted
> > back to you. The JSP properties will display it as is.
> >
> >
> >
> > This has gotten me in the habit of using FormBeans for display purposes.
> >
> >
> >
> > So now I'm thinking, why not add i18N functionality into the FormBean? It
> > seems to me to be a pretty good place to do it.
> >
> >
> >
> > If a field contains a code, you can copy that into the form into the
> > "widgetCode" property, confident that the getter for "widgetText" will
> > convert it for you to the right language.
> >
> >
> >
> > But to do this, you need an ActionForm Object that can store a Locale and
> > a
> > MessageResources bundle.
> >
> >
> >
> > Is there any reason not to? (Form Scoping issues? etc)
> >
> >
> >
> > TIA
> >
> >
> >
> > -Joe
> >
> >
>
>
>
> ---
> avast! Antivirus: Outbound message clean.
> Virus Database (VPS): 0532-6, 08/13/2005
> Tested on: 8/14/2005 9:58:18 AM
> avast! - copyright (c) 2000-2004 ALWIL Software.
> http://www.avast.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Locale Aware Form Objects?
Posted by Eddie Bush <ea...@swbell.net>.
Hi Joe,
I'm not sure I understand your question, but ...
Here's what I do:
I use form beans to tote data around. My labels, OTOH, are externalized and
use bundles to achieve i18n, and this is all fairly transparent on the page.
Here's what I think you want to do:
If I understand you correctly, you want to apply i18n to data the same way
that is commonly done to labels.
I don't like the idea of applying i18n data at the form-level, since that
would require the form to make requests of the model. Rather, my approach
is to have a model with built-in i18n, where I then determine the locale and
translate that to a code that I hand the model when requesting data.
Consequently, I retrieve the data for the proper locale and populate the
form -- lots cleaner, I think.
Is that clear as mud? Did I even understand your question?
Hope so!
Eddie
----- Original Message -----
From: "Joe Hertz" <jh...@speakeasy.net>
To: "'Struts Users Mailing List'" <us...@struts.apache.org>
Sent: Thursday, August 11, 2005 6:29 PM
Subject: Locale Aware Form Objects?
> It seems logical to do, but steadfastly avoided. So I'm wondering if this
> is
> a bad idea or not-
>
>
>
> Example:
>
>
>
> You have a series of i18N'd CRUD screens. On one of them, you allow the
> user
> to retrieve some data, edit it, and save it back.
>
>
>
> On this type of screen, it really makes life easier if you pass the data
> into the screen on an instance of the FormBean that is going to be
> submitted
> back to you. The JSP properties will display it as is.
>
>
>
> This has gotten me in the habit of using FormBeans for display purposes.
>
>
>
> So now I'm thinking, why not add i18N functionality into the FormBean? It
> seems to me to be a pretty good place to do it.
>
>
>
> If a field contains a code, you can copy that into the form into the
> "widgetCode" property, confident that the getter for "widgetText" will
> convert it for you to the right language.
>
>
>
> But to do this, you need an ActionForm Object that can store a Locale and
> a
> MessageResources bundle.
>
>
>
> Is there any reason not to? (Form Scoping issues? etc)
>
>
>
> TIA
>
>
>
> -Joe
>
>
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0532-6, 08/13/2005
Tested on: 8/14/2005 9:58:18 AM
avast! - copyright (c) 2000-2004 ALWIL Software.
http://www.avast.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org