Re: Switching locales with the same link
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:07 To: 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 lines of 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 9247 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
Re: Switching locales with the same link
On 2/13/08, Korsten, Peter, VF-MT [EMAIL PROTECTED] wrote: Incidentally, the languages used will be 'en' and 'mt'... mt == manager talk? Martijn -- Buy Wicket in Action: http://manning.com/dashorst Apache Wicket 1.3.1 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.1 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Switching locales with the same link
Erik van Oosten wrote: Indeed, that's what I did too. Hmm, but the rest was crap I now see. Anyway, glad it got you on the right track. Erik. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Switching locales with the same link
Indeed, that's what I did too. Martijn, mt is Maltese, now that's is something you don't see often in the Netherlands :) Erik. Sebastiaan van Erk wrote: 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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Switching locales with the same link
Yes, you're absolutely right. I got an indication by NetBeans that something was incorrect, but it was apparently about something else. I'd never seen this construct before, and it's not exactly like I'm just starting out with Java. Again, everybody, thanks for the quick replies. off-topic And indeed, 'mt' stands for Malta, an island state in the middle of the Mediterranean Sea. The language is Semitic in nature, most closely related to classic Arabic and Lebanese, yet it is written in the Latin alphabet. In the seven years I've been living here, since moving from my native Netherlands, I haven't been able to learn it. But at least I can write it. I'll drop a line as soon as the project is ready, I suppose you'd like to see Wicket in action. /off-topic - Peter -Original Message- From: Sebastiaan van Erk [mailto:[EMAIL PROTECTED] Sent: 13 February 2008 11:34 To: users@wicket.apache.org Subject: Re: Switching locales with the same link 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 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 9247 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]
Re: Switching locales with the same link
see http://wicketstuff.org/wicket13/pub/ and http://wicketstuff.org/wicket13/pub2 source is available in wicket-examples project -igor On Feb 12, 2008 8:01 AM, Korsten, Peter, VF-MT [EMAIL PROTECTED] wrote: Hi, I've just started with Wicket, and I'm struggling a bit with the documentation. Google hasn't helped either to provide an answer. What I'm after is to have a 'switch locale' link in a different language. Suppose you have an English (default) and a Dutch version, you would have 'Nederlandse versie' on the English page, and 'English version' on the Dutch page. The page is a single HTML page, with the different text labels in properties files. The locale code that you'd want to switch to ('en' for English, 'nl' for Dutch) is stored in the properties files as well. Now, I don't want to make two HTML pages, because this one is going to be used for the navigation structure, and having two pages is undesirable because of the maintenance aspect. I did manage to switch languages, but only by hard-coding the locales in the Java file, checking what the current locale is, and switching to the other one. Whilst it works, it's a clumsy solution. I've considered panels and separate HTML files for the link, but that too looks needlessly complex. 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 lines of getSession().setLocale(new Locale(lc)), where lc is the language code from the link? Thanks, - Peter 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 9247 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]