Re: Internationalized Validators

2015-01-27 Thread Martin Grigorov
Yes! This will make the component tree a bit heavier but it would
definitely simplify the code!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Jan 27, 2015 at 10:02 AM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 You could apply the validator without any switch and build in a check
 which receives the Session Locale and only apply the validation if the
 locale is en_US

 kind regards

 Tobias

  Am 27.01.2015 um 08:40 schrieb Martin Grigorov mgrigo...@apache.org:
 
  On Tue, Jan 27, 2015 at 9:16 AM, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote:
 
  Ah, just one addition: No you would not require to switch the parameter,
  because the parameter would remain the same - in the property files it
  would look like this:
 
  Propertyfile for en_GB:
 
  maxvalue=200
 
  Propertyfile for de_DE:
 
  maxvalue=100
 
  in the code you would receive the max value based on the current locale
  getString(maxvalue)
 
 
  This will work if the app code uses the same type of validator with
  different arguments, but it won't work if for some locales/markets it has
  to use a completely different validator (like AnotherValidatorOnlyForUS).
  But yes, it would simplify the switch!
 
 
 
  kind regards
 
  Tobias
 
  Am 27.01.2015 um 07:38 schrieb Christian Schröter 
  christian.schroe...@1und1.de:
 
 
  Thank you Tobias,
 
  but this will unfortunately just solve the problem having the same
  validator with different parameters. To add a market specific
 validator, I
  still would need to switch case the locale.
 
  Any other ideas?
 
  Hi,
 
  you could place the values in the locale file and parse them.
 
  Integer.parseInt(getString(maxvalue));
 
  kind regards
 
  Tobias
 
  Am 26.01.2015 um 11:01 schrieb Christian Schröter 
  christian.schroe...@1und1.de:
 
  Hey,
 
  I would be interested to know if there is a builtin mechanism to add
  specific validators for a certain locale.
 
  For example:
 
  de_DE - StringValidator.maximumLength(100)
  en_GB - StringValidator.maximumLength(200);
  en_US - StringValidator.maximumLength(200);
   AnotherValidatorOnlyForUS();
 
  My current solution is a switch-case over the locale to add the
  correct validators.
  With more locales and more validators this solution feels kind of
  sloppy.
 
  What does your solution looks like?
 
 
  Cheers,
  Chris
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Internationalized Validators

2015-01-27 Thread Tobias Soloschenko
You could apply the validator without any switch and build in a check which 
receives the Session Locale and only apply the validation if the locale is en_US

kind regards

Tobias

 Am 27.01.2015 um 08:40 schrieb Martin Grigorov mgrigo...@apache.org:
 
 On Tue, Jan 27, 2015 at 9:16 AM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Ah, just one addition: No you would not require to switch the parameter,
 because the parameter would remain the same - in the property files it
 would look like this:
 
 Propertyfile for en_GB:
 
 maxvalue=200
 
 Propertyfile for de_DE:
 
 maxvalue=100
 
 in the code you would receive the max value based on the current locale
 getString(maxvalue)
 
 
 This will work if the app code uses the same type of validator with
 different arguments, but it won't work if for some locales/markets it has
 to use a completely different validator (like AnotherValidatorOnlyForUS).
 But yes, it would simplify the switch!
 
 
 
 kind regards
 
 Tobias
 
 Am 27.01.2015 um 07:38 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 
 Thank you Tobias,
 
 but this will unfortunately just solve the problem having the same
 validator with different parameters. To add a market specific validator, I
 still would need to switch case the locale.
 
 Any other ideas?
 
 Hi,
 
 you could place the values in the locale file and parse them.
 
 Integer.parseInt(getString(maxvalue));
 
 kind regards
 
 Tobias
 
 Am 26.01.2015 um 11:01 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 Hey,
 
 I would be interested to know if there is a builtin mechanism to add
 specific validators for a certain locale.
 
 For example:
 
 de_DE - StringValidator.maximumLength(100)
 en_GB - StringValidator.maximumLength(200);
 en_US - StringValidator.maximumLength(200);
  AnotherValidatorOnlyForUS();
 
 My current solution is a switch-case over the locale to add the
 correct validators.
 With more locales and more validators this solution feels kind of
 sloppy.
 
 What does your solution looks like?
 
 
 Cheers,
 Chris
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Internationalized Validators

2015-01-26 Thread Martin Grigorov
Hi,

I don't see any better way.
Either you use a simple switch statement or a special factory class it is
almost the same - you have to keep it up-to-date with the list of supported
locales/markets.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Jan 27, 2015 at 8:38 AM, Christian Schröter 
christian.schroe...@1und1.de wrote:


 Thank you Tobias,

 but this will unfortunately just solve the problem having the same
 validator with different parameters. To add a market specific validator, I
 still would need to switch case the locale.

 Any other ideas?

  Hi,
 
  you could place the values in the locale file and parse them.
 
  Integer.parseInt(getString(maxvalue));
 
  kind regards
 
  Tobias
 
  Am 26.01.2015 um 11:01 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
  Hey,
 
  I would be interested to know if there is a builtin mechanism to add
 specific validators for a certain locale.
 
  For example:
 
  de_DE - StringValidator.maximumLength(100)
  en_GB - StringValidator.maximumLength(200);
  en_US - StringValidator.maximumLength(200);
   AnotherValidatorOnlyForUS();
 
  My current solution is a switch-case over the locale to add the correct
 validators.
  With more locales and more validators this solution feels kind of
 sloppy.
 
  What does your solution looks like?
 
 
  Cheers,
  Chris
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Internationalized Validators

2015-01-26 Thread Christian Schröter

Thank you Tobias,

but this will unfortunately just solve the problem having the same validator 
with different parameters. To add a market specific validator, I still would 
need to switch case the locale.

Any other ideas?

 Hi,
 
 you could place the values in the locale file and parse them.
 
 Integer.parseInt(getString(maxvalue));
 
 kind regards
 
 Tobias
 
 Am 26.01.2015 um 11:01 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 Hey,
 
 I would be interested to know if there is a builtin mechanism to add 
 specific validators for a certain locale.
 
 For example:
 
 de_DE - StringValidator.maximumLength(100)
 en_GB - StringValidator.maximumLength(200);
 en_US - StringValidator.maximumLength(200);
  AnotherValidatorOnlyForUS();
 
 My current solution is a switch-case over the locale to add the correct 
 validators.
 With more locales and more validators this solution feels kind of sloppy.
 
 What does your solution looks like?
 
 
 Cheers,
 Chris
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Internationalized Validators

2015-01-26 Thread Tobias Soloschenko
Hi,

you could switch the locale of the session 

http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/protocol/http/WebSession.html

setLocale(Locale locale)

Here is an example in which the locale is switched by a link click:

https://cwiki.apache.org/confluence/display/WICKET/Manually+switching+locale

For normal the locale is resolved by the preferred language of the browser.

You may switch the locale based on the market which is currently displayed.

I don't know if it is possible to switch the locale of a component Hierarchy.

Here the link to the user guide for i18n:

http://wicket.apache.org/guide/guide/i18n.html

kind regards

Tobias

 Am 27.01.2015 um 07:38 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 
 Thank you Tobias,
 
 but this will unfortunately just solve the problem having the same validator 
 with different parameters. To add a market specific validator, I still would 
 need to switch case the locale.
 
 Any other ideas?
 
 Hi,
 
 you could place the values in the locale file and parse them.
 
 Integer.parseInt(getString(maxvalue));
 
 kind regards
 
 Tobias
 
 Am 26.01.2015 um 11:01 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 Hey,
 
 I would be interested to know if there is a builtin mechanism to add 
 specific validators for a certain locale.
 
 For example:
 
 de_DE - StringValidator.maximumLength(100)
 en_GB - StringValidator.maximumLength(200);
 en_US - StringValidator.maximumLength(200);
  AnotherValidatorOnlyForUS();
 
 My current solution is a switch-case over the locale to add the correct 
 validators.
 With more locales and more validators this solution feels kind of sloppy.
 
 What does your solution looks like?
 
 
 Cheers,
 Chris
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Internationalized Validators

2015-01-26 Thread Tobias Soloschenko
Ah, just one addition: No you would not require to switch the parameter, 
because the parameter would remain the same - in the property files it would 
look like this:

Propertyfile for en_GB:

maxvalue=200

Propertyfile for de_DE:

maxvalue=100

in the code you would receive the max value based on the current locale 
getString(maxvalue)

kind regards

Tobias

 Am 27.01.2015 um 07:38 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 
 Thank you Tobias,
 
 but this will unfortunately just solve the problem having the same validator 
 with different parameters. To add a market specific validator, I still would 
 need to switch case the locale.
 
 Any other ideas?
 
 Hi,
 
 you could place the values in the locale file and parse them.
 
 Integer.parseInt(getString(maxvalue));
 
 kind regards
 
 Tobias
 
 Am 26.01.2015 um 11:01 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 Hey,
 
 I would be interested to know if there is a builtin mechanism to add 
 specific validators for a certain locale.
 
 For example:
 
 de_DE - StringValidator.maximumLength(100)
 en_GB - StringValidator.maximumLength(200);
 en_US - StringValidator.maximumLength(200);
  AnotherValidatorOnlyForUS();
 
 My current solution is a switch-case over the locale to add the correct 
 validators.
 With more locales and more validators this solution feels kind of sloppy.
 
 What does your solution looks like?
 
 
 Cheers,
 Chris
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Internationalized Validators

2015-01-26 Thread Martin Grigorov
On Tue, Jan 27, 2015 at 9:16 AM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 Ah, just one addition: No you would not require to switch the parameter,
 because the parameter would remain the same - in the property files it
 would look like this:

 Propertyfile for en_GB:

 maxvalue=200

 Propertyfile for de_DE:

 maxvalue=100

 in the code you would receive the max value based on the current locale
 getString(maxvalue)


This will work if the app code uses the same type of validator with
different arguments, but it won't work if for some locales/markets it has
to use a completely different validator (like AnotherValidatorOnlyForUS).
But yes, it would simplify the switch!



 kind regards

 Tobias

  Am 27.01.2015 um 07:38 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 
  Thank you Tobias,
 
  but this will unfortunately just solve the problem having the same
 validator with different parameters. To add a market specific validator, I
 still would need to switch case the locale.
 
  Any other ideas?
 
  Hi,
 
  you could place the values in the locale file and parse them.
 
  Integer.parseInt(getString(maxvalue));
 
  kind regards
 
  Tobias
 
  Am 26.01.2015 um 11:01 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
  Hey,
 
  I would be interested to know if there is a builtin mechanism to add
 specific validators for a certain locale.
 
  For example:
 
  de_DE - StringValidator.maximumLength(100)
  en_GB - StringValidator.maximumLength(200);
  en_US - StringValidator.maximumLength(200);
   AnotherValidatorOnlyForUS();
 
  My current solution is a switch-case over the locale to add the
 correct validators.
  With more locales and more validators this solution feels kind of
 sloppy.
 
  What does your solution looks like?
 
 
  Cheers,
  Chris
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Internationalized Validators

2015-01-26 Thread Christian Schröter
Hey,

I would be interested to know if there is a builtin mechanism to add specific 
validators for a certain locale.

For example:

de_DE - StringValidator.maximumLength(100)
en_GB - StringValidator.maximumLength(200);
en_US - StringValidator.maximumLength(200);
 AnotherValidatorOnlyForUS();

My current solution is a switch-case over the locale to add the correct 
validators.
With more locales and more validators this solution feels kind of sloppy.

What does your solution looks like?


Cheers,
Chris


Re: Internationalized Validators

2015-01-26 Thread Tobias Soloschenko
Hi,

you could place the values in the locale file and parse them.

Integer.parseInt(getString(maxvalue));

kind regards

Tobias

 Am 26.01.2015 um 11:01 schrieb Christian Schröter 
 christian.schroe...@1und1.de:
 
 Hey,
 
 I would be interested to know if there is a builtin mechanism to add specific 
 validators for a certain locale.
 
 For example:
 
 de_DE - StringValidator.maximumLength(100)
 en_GB - StringValidator.maximumLength(200);
 en_US - StringValidator.maximumLength(200);
  AnotherValidatorOnlyForUS();
 
 My current solution is a switch-case over the locale to add the correct 
 validators.
 With more locales and more validators this solution feels kind of sloppy.
 
 What does your solution looks like?
 
 
 Cheers,
 Chris

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org