You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pierre Métras <ge...@sympatico.ca> on 2000/08/22 16:33:43 UTC

Locale detection

Hello,

As I mentioned last week, here are two simple tags for other struts users
that may be interested in.

<struts:detectLocale /> will try to negociate with the client browser a
locale to retrieve message resources. In case of success, the locale is kept
in the user session and automatically available to all <struts:message />
tags.

<struts:forwardName name="..." /> simply prints the URL corresponding to the
global forward. This one can be used in JavaScript code to use struts
forwards instead of hard-coded URL.

I hope I didn't introduced syntax errors when moving them from my
application taglib to struts, as I can't presently test the result.

Pierre Métras

Re: Locale detection

Posted by Chris Miller <ki...@vardus.co.uk>.
Oh I see! Thanks for the clarification. Hopefully your tag will get included
into struts then since it sounds useful (I'd thought that's what the forward
tag did, but I just looked at the code for it and you're right).

----- Original Message -----
From: "Pierre Métras" <ge...@sympatico.ca>
To: <st...@jakarta.apache.org>
Sent: Tuesday, August 22, 2000 4:37 PM
Subject: Re: Locale detection


> Hi Chris,
>
> From my understanding (I haven't used it either), the <forward /> tags
looks
> up a forward name and then performs the forward or redirection, sending
the
> headers to the client browser.
> My <forwardName /> only does the look up to obtain the real URL and print
it
> in the flow. Then the page can decide what to do with the URL: embed it in
a
> <a> link, just like <struts:link>; use it in JavaScript code; or just
print
> it...
>
> Pierre Métras
>
> ----- Original Message -----
> From: "Chris Miller" <ki...@vardus.co.uk>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, August 22, 2000 10:45 AM
> Subject: Re: Locale detection
>
>
> > I'm curious. Not that I've used either, but I can't see what the
> difference
> > is between your forwardName tag and the <struts:forward> tag that
already
> > exists (in the documentation at least!)?
> >
> > ----- Original Message -----
> > From: "Pierre Métras" <ge...@sympatico.ca>
> > To: <st...@jakarta.apache.org>
> > Sent: Tuesday, August 22, 2000 3:33 PM
> > Subject: Locale detection
> >
> >
> > > Hello,
> > >
> > > As I mentioned last week, here are two simple tags for other struts
> users
> > > that may be interested in.
> > >
> > > <struts:detectLocale /> will try to negociate with the client browser
a
> > > locale to retrieve message resources. In case of success, the locale
is
> > kept
> > > in the user session and automatically available to all <struts:message
> />
> > > tags.
> > >
> > > <struts:forwardName name="..." /> simply prints the URL corresponding
to
> > the
> > > global forward. This one can be used in JavaScript code to use struts
> > > forwards instead of hard-coded URL.
> > >
> > > I hope I didn't introduced syntax errors when moving them from my
> > > application taglib to struts, as I can't presently test the result.
> > >
> > > Pierre Métras
> > >
> >
> >
>
>


Re: Locale detection

Posted by Pierre Métras <ge...@sympatico.ca>.
Hi Chris,

Re: Question on Users Guide: Multiple HTML Form into one FormBean

Posted by Hans Gerwitz <ja...@phobia.com>.
> So I am wondering how this can be done if any of the values has to be
> validated (e.g. DateFormat or required or ....) if I do not know if the user
> has not specified a value or it is not within the form (but in one of the
> next ones). Is there any way to detect which values have been modified/set
> within the current request (beside looking into the HttpRequest on my own,
> which would mean that one of the benefits of using struts will be gone).

A common solution to "step-by-step" validation is to have a "step" property
that is exposed as a hidden form field on each page, then the validate()
method can choose which fields to validate based on that property.

If you want a "clean" implementation that avoids the form bean having to
understand which fields are in which step, I would suggest having the bean
track which properties have been set (via setter methods that set a boolean
or add their name to a hashtable, etc); then your validate() can be "smart"
about which properties need to be set.  A caveat, though: to confirm that a
page designer did not forget a field, add a "formComplete" property that is
set to true as a hidden input on the final step, and triggers the validate()
method to check everything.

Hope that helps,
-- 
Hans Gerwitz
hans@phobia.com


Question on Users Guide: Multiple HTML Form into one FormBean

Posted by Stefan Wesner <we...@rus.uni-stuttgart.de>.
Hi,

I just started using struts and I finished the users guide and a small
sample app.

Now I want to do a larger Application that has serveral pages that all
together build a "project proposal".

In the users guide there is explicitely mentioned that it is useful to have
multiple HTML pages containing forms mapped to *one* ActionForm if they
belong together in order to have no dependency between the arrangement of
form elements and the actual FormBean implementation.

So I am wondering how this can be done if any of the values has to be
validated (e.g. DateFormat or required or ....) if I do not know if the user
has not specified a value or it is not within the form (but in one of the
next ones). Is there any way to detect which values have been modified/set
within the current request (beside looking into the HttpRequest on my own,
which would mean that one of the benefits of using struts will be gone).

Any more detailed examples/texts on that issue ?

Stefan Wesner.

--
Dipl.-Ing. Stefan Wesner     Head of Software Technology Group
phone: +49 (0)711 685-4275   fax: +49 (0)711 682-357
mailto:wesner@rus.uni-stuttgart.de
Rechenzentrum Universität Stuttgart 70550 Stuttgart Germany


Re: Locale detection

Posted by Chris Miller <ki...@vardus.co.uk>.
I'm curious. Not that I've used either, but I can't see what the difference
is between your forwardName tag and the <struts:forward> tag that already
exists (in the documentation at least!)?

----- Original Message -----
From: "Pierre Métras" <ge...@sympatico.ca>
To: <st...@jakarta.apache.org>
Sent: Tuesday, August 22, 2000 3:33 PM
Subject: Locale detection


> Hello,
>
> As I mentioned last week, here are two simple tags for other struts users
> that may be interested in.
>
> <struts:detectLocale /> will try to negociate with the client browser a
> locale to retrieve message resources. In case of success, the locale is
kept
> in the user session and automatically available to all <struts:message />
> tags.
>
> <struts:forwardName name="..." /> simply prints the URL corresponding to
the
> global forward. This one can be used in JavaScript code to use struts
> forwards instead of hard-coded URL.
>
> I hope I didn't introduced syntax errors when moving them from my
> application taglib to struts, as I can't presently test the result.
>
> Pierre Métras
>