Like in the code given, you can just use : HomePage.this.getString("header.versionLanguage")
in the anonymous inner class instead of using the "trick" you mention. The reference of the page is *already* passed to the anonymous inner class (by java itself, since anonymous inner classes are not and cannot be static), now you are actually causing the reference to be stored twice.
Regards, Sebastiaan Korsten, Peter, VF-MT wrote:
Dankjewel! :) I had to tweak the code below a bit, in order to get it working, but this is what I ended up with: public HomePage() { final Component parentPage = this; add( new Link( "languageSwitch" ) { @Override public void onClick() { String language = parentPage.getString( "header.versionLanguage" ); Locale locale = new Locale( language ); this.getSession().setLocale( locale ); } } ); } The trick is to pass a reference of the page to the anonymous inner class. Incidentally, the languages used will be 'en' and 'mt'...- Peter-----Original Message-----From: Erik van Oosten [mailto:[EMAIL PROTECTED] Sent: 13 February 2008 10:07To: users@wicket.apache.org Subject: Re: Switching locales with the same link Hi Peter, Yes, you can do this. Suppose the link is in LocalePanel, then LocalePanel.properties: other_locale: nl_NL LocalePanel_en.properties: other_locale: en_US LocalePanel.java: add(new Link("localeLink", new Model() { public Object getObject() { Locale l = new Locale(LocalePanel.this.get("other_locale")); getSession().setLocale(l); } }); Or something like that :) Regards, Erik. Korsten, Peter, VF-MT wrote:So, is it possible to make a link that takes the language code from the properties file as a parameter, and does something along the linesof getSession().setLocale(new Locale(lc)), where lc is the language code from the link?--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] There is only one of you for all time. Fearlessly be yourself. Life is Now! ------------------------------------------------------------------- This email is intended only for the use of individuals to whom it is addressed, as it may contain confidential or privileged information. If you are not a named addressee, intended recipient, or the person responsible for delivering the message to the named addressee, be advised that you have received this email in error and that you should not disseminate, distribute, print, copy this mail or otherwise divulge its contents. In such instances, please notify Vodafone Malta Limited on telephone number +356 99999247 and delete this email from your system. Since this transmission was affected via email, Vodafone Malta Limited cannot guarantee that it is secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. Vodafone Malta Limited does not accept liability for any errors or omissions in the contents of this message which arise as a result of email transmission. Save the environment for our children - Print e-mail only when necessary. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME Cryptographic Signature