Localization questions

2015-02-26 Thread Maxim Solodovnik
Hello All,

I have couple of questions related to localization:

1) is there any way to list all available locales in Application?

let's say I have Application.properties.xml, Application_de.properties.xml,
Application_ru.properties.xml, I would like to get list of Locale.EN,
Locale.DE, Locale.RU in such case, is it possible?

2) Is there any way to get string in given Locale different from
WebSession.locale?

I would like to create email based on template in language of receiver,
is it possible?

Thanks in advance!

-- 
WBR
Maxim aka solomax


Re: Localization questions

2015-02-26 Thread Tobias Soloschenko
Hi,

As far as I know it is like this:

1) Every component is providing the current locale which is configured by the 
preferred language of the browser via #getLocale() derived from the websession 
or its parent (but root is from websession)

I think there is no way to get a list of all languages, because each component 
is translating the content based on found properties (e.g myproperty_de_De)

2) If the receiver is accessing your application with it's preferred language 
(configured in the browser) you could simply write properties for the specific 
locale and generate the template without any switch / if statements - if the 
language is not supported you could add properties without any locale 
Information and apply english translations as fallback.

kind regards

Tobias

 Am 26.02.2015 um 12:22 schrieb Maxim Solodovnik solomax...@gmail.com:
 
 Hello All,
 
 I have couple of questions related to localization:
 
 1) is there any way to list all available locales in Application?
 
 let's say I have Application.properties.xml, Application_de.properties.xml,
 Application_ru.properties.xml, I would like to get list of Locale.EN,
 Locale.DE, Locale.RU in such case, is it possible?
 
 2) Is there any way to get string in given Locale different from
 WebSession.locale?
 
 I would like to create email based on template in language of receiver,
 is it possible?
 
 Thanks in advance!
 
 -- 
 WBR
 Maxim aka solomax

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



Re: Localization questions

2015-02-26 Thread Sven Meier

2)
Wicket's Localizer offers several methods with locale parameter, you can 
get it via component.getLocalizer().


Sven

On 26.02.2015 12:22, Maxim Solodovnik wrote:

Hello All,

I have couple of questions related to localization:

1) is there any way to list all available locales in Application?

let's say I have Application.properties.xml, Application_de.properties.xml,
Application_ru.properties.xml, I would like to get list of Locale.EN,
Locale.DE, Locale.RU in such case, is it possible?

2) Is there any way to get string in given Locale different from
WebSession.locale?

I would like to create email based on template in language of receiver,
is it possible?

Thanks in advance!




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



Re: Localization questions

2015-02-26 Thread Tobias Soloschenko
Oh yes! :-) Forgot to mention Localizer! 

kind regards

Tobias

 Am 26.02.2015 um 12:38 schrieb Sven Meier s...@meiers.net:
 
 2)
 Wicket's Localizer offers several methods with locale parameter, you can get 
 it via component.getLocalizer().
 
 Sven
 
 On 26.02.2015 12:22, Maxim Solodovnik wrote:
 Hello All,
 
 I have couple of questions related to localization:
 
 1) is there any way to list all available locales in Application?
 
 let's say I have Application.properties.xml, Application_de.properties.xml,
 Application_ru.properties.xml, I would like to get list of Locale.EN,
 Locale.DE, Locale.RU in such case, is it possible?
 
 2) Is there any way to get string in given Locale different from
 WebSession.locale?
 
 I would like to create email based on template in language of receiver,
 is it possible?
 
 Thanks in advance!
 
 
 -
 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: Localization questions

2015-02-26 Thread Maxim Solodovnik
Thanks a lot!

Localizer seems to be exactly what I need :)

On Thu, Feb 26, 2015 at 5:42 PM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 Oh yes! :-) Forgot to mention Localizer!

 kind regards

 Tobias

  Am 26.02.2015 um 12:38 schrieb Sven Meier s...@meiers.net:
 
  2)
  Wicket's Localizer offers several methods with locale parameter, you can
 get it via component.getLocalizer().
 
  Sven
 
  On 26.02.2015 12:22, Maxim Solodovnik wrote:
  Hello All,
 
  I have couple of questions related to localization:
 
  1) is there any way to list all available locales in Application?
 
  let's say I have Application.properties.xml,
 Application_de.properties.xml,
  Application_ru.properties.xml, I would like to get list of Locale.EN,
  Locale.DE, Locale.RU in such case, is it possible?
 
  2) Is there any way to get string in given Locale different from
  WebSession.locale?
 
  I would like to create email based on template in language of
 receiver,
  is it possible?
 
  Thanks in advance!
 
 
  -
  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




-- 
WBR
Maxim aka solomax


Using forms defined in panels

2015-02-26 Thread Andrew Hall
Hi all,
I have a newbie question ...
In the free online guide for Wicket - best practices section,2 listings are 
provided as examples of how to encapsulate components in panels:
(http://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_1)
Listing 3:// Good component
public class RegistrationInputPanel extends Panel{
public RegistrationInputPanel(String id, IModelRegistration regModel) {
super(id, regModel);
IModelRegistration compound = new 
CompoundPropertyModelRegistration(regmodel)
FormRegistration form = new FormRegistration(form, compound);
// Correct: Add components to Form over the instance variable
form.add(new TextField(username));
form.add(new TextField(firstname));
form.add(new TextField(lastname));
add(form);
}
}
Listing 4:public class RegistrationPage extends Page {
public RegistrationPage(IModelRegistration regModel) {
Form? form = new Form(form);
form.add(new RegistrationInputPanel(registration, regModel);
form.add(new SubmitButton(register) {
public void onSubmit() {
  // do something
}
});
add(form);
}
}
I infer from this example that it is possible in Wicket to decouple the 
physical definition of a form (listing 3) from the code which is executed when 
a form is submitted (listing 4). I suppose the point is that different pages 
can reuse the same physical form and implement their own form submission logic.
Is it possible for the // do something in listing 4 to access the values of 
username, firstname  lastname submitted through the form defined in 
listing 3?
If the answer is yes, then could anyone provide a snippet of code demonstrating 
how to do this? I've had a search and have not found an obvious way!
Thanks,
Andrew.   

Re: Using forms defined in panels

2015-02-26 Thread Sven Meier

Hi,

the easiest solution is declare regModel as final, then you can do something 
as follows:
 
form.add(new SubmitButton(register) {

public void onSubmit() {
  // do something
  regModel.getObject().getUserName();
}
});

Note that declaring models as final might me dangerous, since the model 
is kept in the component hierarchy but nobody detaches it. This is not 
the case here though, since RegistrationInputPanel will take care of it.


Regards
Sven

On 26.02.2015 09:18, Andrew Hall wrote:

Hi all,
I have a newbie question ...
In the free online guide for Wicket - best practices section,2 listings are 
provided as examples of how to encapsulate components in panels:
(http://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_1)
Listing 3:// Good component
public class RegistrationInputPanel extends Panel{
 public RegistrationInputPanel(String id, IModelRegistration regModel) {
 super(id, regModel);
 IModelRegistration compound = new 
CompoundPropertyModelRegistration(regmodel)
 FormRegistration form = new FormRegistration(form, compound);
 // Correct: Add components to Form over the instance variable
 form.add(new TextField(username));
 form.add(new TextField(firstname));
 form.add(new TextField(lastname));
 add(form);
 }
}
Listing 4:public class RegistrationPage extends Page {
 public RegistrationPage(IModelRegistration regModel) {
 Form? form = new Form(form);
 form.add(new RegistrationInputPanel(registration, regModel);
 form.add(new SubmitButton(register) {
 public void onSubmit() {
   // do something
 }
 });
 add(form);
 }
}
I infer from this example that it is possible in Wicket to decouple the 
physical definition of a form (listing 3) from the code which is executed when 
a form is submitted (listing 4). I suppose the point is that different pages 
can reuse the same physical form and implement their own form submission logic.
Is it possible for the // do something in listing 4 to access the values of username, 
firstname  lastname submitted through the form defined in listing 3?
If the answer is yes, then could anyone provide a snippet of code demonstrating 
how to do this? I've had a search and have not found an obvious way!
Thanks,
Andrew. 



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