On Fri, 14 Dec 2001, Ted Husted wrote:

> Date: Fri, 14 Dec 2001 19:39:54 -0500
> From: Ted Husted <[EMAIL PROTECTED]>
> Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> To: Struts Developers List <[EMAIL PROTECTED]>
> Subject: Re: i18n Forwards
>
> OK, next question.
>
> What if they want to use their own helper object to change the pattern?
>
> Say, a browser-detection bean?
>
> So, the "smart forward" has some replacement switch.
>
> When the switch is true, it calls a method that returns a string.
>
> The string is merged into the path (or equivalent field).
>
> The locale version is then a concrete implementation that uses the local
> helper in the session.
>

Doing something smart (like a browser-detection mechanism) sounds like a
good case for an application subclass of ActionForward that overrides the
getPath(Locale) method.  Perhaps we should pass in the current request,
instead of the Locale, so that the method could get whatever it needed.

> If we want to be really stupid, one version could return an array, and
> look for {0}, {1}.
>
> BTW, why is it that we don't use an array for the message replacements.
> Something to do with the taglibs?
>

You mean in the getMessage() method signatures?  It'd be pretty easy to
add one more overloaded method that takes an array instead.

Craig


>
> "Craig R. McClanahan" wrote:
> >
> > On Fri, 14 Dec 2001, Ted Husted wrote:
> >
> > > Date: Fri, 14 Dec 2001 18:18:18 -0500
> > > From: Ted Husted <[EMAIL PROTECTED]>
> > > Reply-To: Struts Developers List <[EMAIL PROTECTED]>
> > > To: [EMAIL PROTECTED]
> > > Subject: i18n Forwards
> > >
> > > Have we ever talked about a standard subclass for ActionForward that
> > > would automatically expand a path based on the user's locale. I'm pretty
> > > sure this has come up on the user list, where people were changing the
> > > forward dynamically in the Action. But maybe we should have a standard
> > > ActionForward subclass so that you could do like
> > >
> > > <forward name="whatever" path="\pages\{*}\whatever.jsp" locale="true"/>
> > >
> > > and have it expand to
> > >
> > > \pages\es\whatever.jsp or
> > > \pages\en\whatever.jsp
> > >
> > > at runtime.
> > >
> > > Or is that too application specific?
> > >
> > > The message resources are great for cobbling together messages, but I
> > > doubt that it would be a good solution for larger sites.
> > >
> > > But then, what do I know about i18n projects ;-)
> > >
> >
> > I like the idea.
> >
> > I think the Apache pattern is to add a Locale suffix (/pages/whatever.jsp
> > --> /pages/whatever.jsp.es).  This would probably not work well when JSP
> > pages are extension mapped, but using a replacement pattern lets the user
> > configure this to match their own environment.
> >
> > I would suggest the following as implementation considerations:
> >
> > * We can just make the existing ActionForward class smarter by adding
> >   a Locale property that defaults to "false".
> >
> > * IMHO, the existing "path" property getter method should continue to
> >   return the pattern itself.
> >
> > * We would add new getPath(Locale locale) method (or some such) that
> >   performs the replacement if locale is true, or the value of getPath()
> >   if locale is false.
> >
> > * Perhaps the replacement code in the pattern should be {0} so that it
> >   acts like internationalized message strings in resource bundles?
> >
> > Craig
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to