You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by btakacs <ta...@gmail.com> on 2008/08/26 14:23:40 UTC
Localization issue
Hi
I have a page with a TabPanel with a ListView of BookmarkableLinks, and with
some contents. I would need to reload the TabPanel, and the contents after
changing the locale.
I tried the following, but haven't succeeded:
add(new Link("enSwitch") {
@Override
public final void onClick() {
Locale locale = new Locale("en");
this.getSession().setLocale(locale);
setResponsePage(this.getPage());
}
});
My Tab implementation is the following:
public class MenuTab extends AbstractTab {
Panel panel;
public MenuTab(IModel title) {
super(title);
}
public MenuTab(IModel title, Panel panel) {
super(title);
this.panel=panel;
}
@Override
public Panel getPanel(String panelId) {
return panel;
}
}
My View implementation inherits the ListView, and overrides only the
populateItem method.
Do you have any tips?
Thanks:
Bence
--
View this message in context: http://www.nabble.com/Localization-issue-tp19160932p19160932.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by James Carman <ja...@carmanconsulting.com>.
This isn't a browser setting. This is overriding the locale via code
rather than using the browser default. This wiki page outlines all
you need to know about i18n in Wicket:
http://cwiki.apache.org/WICKET/i18n.html
2008/8/26 Łukasz Lipka <lu...@gmail.com>:
> Hi,
> depends on browser you use, I think for IE you have to start a new Broswer,
> for Firefox you can try this:
> getSession().invalidate(); and than set up new Locale
>
> Best regards
> Łukasz Lipka
>
> 2008/8/26 btakacs <ta...@gmail.com>
>
>>
>> Hi
>>
>> I have a page with a TabPanel with a ListView of BookmarkableLinks, and
>> with
>> some contents. I would need to reload the TabPanel, and the contents after
>> changing the locale.
>>
>> I tried the following, but haven't succeeded:
>>
>> add(new Link("enSwitch") {
>>
>> @Override
>> public final void onClick() {
>> Locale locale = new Locale("en");
>> this.getSession().setLocale(locale);
>> setResponsePage(this.getPage());
>> }
>>
>> });
>>
>>
>> My Tab implementation is the following:
>>
>> public class MenuTab extends AbstractTab {
>>
>> Panel panel;
>>
>> public MenuTab(IModel title) {
>> super(title);
>> }
>>
>> public MenuTab(IModel title, Panel panel) {
>> super(title);
>> this.panel=panel;
>> }
>>
>> @Override
>> public Panel getPanel(String panelId) {
>> return panel;
>> }
>> }
>>
>>
>> My View implementation inherits the ListView, and overrides only the
>> populateItem method.
>>
>> Do you have any tips?
>>
>> Thanks:
>> Bence
>> --
>> View this message in context:
>> http://www.nabble.com/Localization-issue-tp19160932p19160932.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
Re: Localization issue
Posted by Łukasz Lipka <lu...@gmail.com>.
Hi,
depends on browser you use, I think for IE you have to start a new Broswer,
for Firefox you can try this:
getSession().invalidate(); and than set up new Locale
Best regards
Łukasz Lipka
2008/8/26 btakacs <ta...@gmail.com>
>
> Hi
>
> I have a page with a TabPanel with a ListView of BookmarkableLinks, and
> with
> some contents. I would need to reload the TabPanel, and the contents after
> changing the locale.
>
> I tried the following, but haven't succeeded:
>
> add(new Link("enSwitch") {
>
> @Override
> public final void onClick() {
> Locale locale = new Locale("en");
> this.getSession().setLocale(locale);
> setResponsePage(this.getPage());
> }
>
> });
>
>
> My Tab implementation is the following:
>
> public class MenuTab extends AbstractTab {
>
> Panel panel;
>
> public MenuTab(IModel title) {
> super(title);
> }
>
> public MenuTab(IModel title, Panel panel) {
> super(title);
> this.panel=panel;
> }
>
> @Override
> public Panel getPanel(String panelId) {
> return panel;
> }
> }
>
>
> My View implementation inherits the ListView, and overrides only the
> populateItem method.
>
> Do you have any tips?
>
> Thanks:
> Bence
> --
> View this message in context:
> http://www.nabble.com/Localization-issue-tp19160932p19160932.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Localization issue
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Yeah this seems to be the issue...
Janos Cserep wrote:
>
>> Actually now I have only one label for testing purposes:
>> add(new Label("locale", getSession().getLocale().getLanguage()));
>
> That's actually bad practice. You are adding the component in the
> constructor. That code runs only once - when you create the component,
> page, etc.
>
> Try:
>
> add(new Label("locale", new PropertyModel(this,
> "session.locale.language"));
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by btakacs <ta...@gmail.com>.
Thanks, it works!
Janos Cserep-4 wrote:
>
>
>> Actually now I have only one label for testing purposes:
>> add(new Label("locale", getSession().getLocale().getLanguage()));
>>
>
> That's actually bad practice. You are adding the component in the
> constructor. That code runs only once - when you create the component,
> page, etc.
>
> Try:
>
> add(new Label("locale", new PropertyModel(this,
> "session.locale.language"));
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Localization-issue-tp19160932p19221098.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by Janos Cserep <cs...@euedge.com>.
> Actually now I have only one label for testing purposes:
> add(new Label("locale", getSession().getLocale().getLanguage()));
>
That's actually bad practice. You are adding the component in the
constructor. That code runs only once - when you create the component,
page, etc.
Try:
add(new Label("locale", new PropertyModel(this, "session.locale.language"));
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by btakacs <ta...@gmail.com>.
Janos Cserep-4 wrote:
>
> Are you setting up your components based on your locale in the
> constructor?
>
Actually now I have only one label for testing purposes:
add(new Label("locale", getSession().getLocale().getLanguage()));
> Because if you do, then setting a Page object with setResponsePage won't
> create new component objects for you.
>
> Try:
>
> setResponsePage(this.getPage().getClass()); - this will forward you to a
> new instance of the page...
>
Well, it seems to help. It seems that the method with Class type forces the
reload.
It's weird a little...
Thanks
Bence
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
--
View this message in context: http://www.nabble.com/Localization-issue-tp19160932p19180156.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by Janos Cserep <cs...@euedge.com>.
> why the locale changes does not apply to the components?
>
Are you setting up your components based on your locale in the constructor?
Because if you do, then setting a Page object with setResponsePage won't
create new component objects for you.
Try:
setResponsePage(this.getPage().getClass()); - this will forward you to a
new instance of the page...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by James Carman <ja...@carmanconsulting.com>.
Try setRedirect(true). The locale for the current request is probably
already established.
On Tue, Aug 26, 2008 at 3:56 PM, btakacs <ta...@gmail.com> wrote:
>
> Hi, All
>
> The question is:
> after
> getSession().setLocale(locale);
> running and successfully changing the locale (I checked in debug mode)
>
> when running
> setResponsePage(this.getPage());
> why the locale changes does not apply to the components?
>
> They apply only after I click on a bookmarkable link.
>
> Now it does not seem to be a Localization issue: it's some kind of reload
> issue...
>
> Any tips?
>
> Thanks:
> Bence
>
>
> --
> View this message in context: http://www.nabble.com/Localization-issue-tp19160932p19169188.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Ok
This is my code for a locale switching link that will disable when active:
@Override
protected WebMarkupContainer getLocaleComponent(String id,
final Locale locale) {
Link link = new Link(id) {
@Override
public void onClick() {
getSession().setLocale(locale);
this.setEnabled(false);
}protected void onBeforeRender() {
super.onBeforeRender();
this.setEnabled(!locale.equals(getSession().getLocale()));
};
};
return link;
}
It works just fine, with 1.3.4 .
When using page parameter & bookmarkable links it looks like this, no
redirection involved:
protected WebMarkupContainer getLocaleComponent(String id, Locale
locale) {
BookmarkablePageLink bookmarkablePageLink = new
BookmarkablePageLink(
id, this.getClass(), getPageParameters(locale));
if (locale.equals(getSession().getLocale())) {
bookmarkablePageLink.setEnabled(false);
}
return bookmarkablePageLink;
}
protected PageParameters getPageParameters(Locale locale) {
PageParameters pageParameters = new PageParameters();
if (pageParameters.containsKey("locale")) {
pageParameters.remove("locale");
}
pageParameters.add("locale", locale.getLanguage());
return pageParameters;
}
btakacs wrote:
> I haven't added ajax support, and I am still having that problem.
>
>
>
> Nino.Martinez wrote:
>
>> Yeah, I were just uncertain if you might had added some ajax that were
>> causing the problem..
>>
>> you are still having problems?
>>
>> btakacs wrote:
>>
>>> Hi
>>>
>>> Yeah, I understand that it is working with Ajax. But first I wanted to
>>> make
>>> it without ajax. Later I can upgrade.
>>> I don't know yet how can I ajaxify my pages, and this should work without
>>> ajax.
>>>
>>> Bence
>>>
>>>
>>>
>>> Nino.Martinez wrote:
>>>
>>>
>>>> Yeah I can confirm what Daniel are saying.. I have the same approach..
>>>> On the otherhand if it's an ajax link you'll need to add all the
>>>> components you want rerendered.
>>>>
>>>> Daniel Stoch wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> But what exactly not work?
>>>>>
>>>>> I'm using a Link with onClick() code:
>>>>> getSession().setLocale(locale);
>>>>> to swicth current locale and everything works ok. All page components
>>>>> are localized correctly.
>>>>>
>>>>> I think this setResponsePage(this.getPage()); call in your code is
>>>>> not necessary:
>>>>> @Override
>>>>> public final void onClick() {
>>>>> Locale locale = new Locale("en");
>>>>> this.getSession().setLocale(locale);
>>>>> setResponsePage(this.getPage());
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>> --
>>>> -Wicket for love
>>>>
>>>> Nino Martinez Wael
>>>> Java Specialist @ Jayway DK
>>>> http://www.jayway.dk
>>>> +45 2936 7684
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>>
>
>
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by btakacs <ta...@gmail.com>.
I haven't added ajax support, and I am still having that problem.
Nino.Martinez wrote:
>
> Yeah, I were just uncertain if you might had added some ajax that were
> causing the problem..
>
> you are still having problems?
>
> btakacs wrote:
>> Hi
>>
>> Yeah, I understand that it is working with Ajax. But first I wanted to
>> make
>> it without ajax. Later I can upgrade.
>> I don't know yet how can I ajaxify my pages, and this should work without
>> ajax.
>>
>> Bence
>>
>>
>>
>> Nino.Martinez wrote:
>>
>>> Yeah I can confirm what Daniel are saying.. I have the same approach..
>>> On the otherhand if it's an ajax link you'll need to add all the
>>> components you want rerendered.
>>>
>>> Daniel Stoch wrote:
>>>
>>>> Hi,
>>>>
>>>> But what exactly not work?
>>>>
>>>> I'm using a Link with onClick() code:
>>>> getSession().setLocale(locale);
>>>> to swicth current locale and everything works ok. All page components
>>>> are localized correctly.
>>>>
>>>> I think this setResponsePage(this.getPage()); call in your code is
>>>> not necessary:
>>>> @Override
>>>> public final void onClick() {
>>>> Locale locale = new Locale("en");
>>>> this.getSession().setLocale(locale);
>>>> setResponsePage(this.getPage());
>>>> }
>>>>
>>>>
>>>>
>>> --
>>> -Wicket for love
>>>
>>> Nino Martinez Wael
>>> Java Specialist @ Jayway DK
>>> http://www.jayway.dk
>>> +45 2936 7684
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>>
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Localization-issue-tp19160932p19177447.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Yeah, I were just uncertain if you might had added some ajax that were
causing the problem..
you are still having problems?
btakacs wrote:
> Hi
>
> Yeah, I understand that it is working with Ajax. But first I wanted to make
> it without ajax. Later I can upgrade.
> I don't know yet how can I ajaxify my pages, and this should work without
> ajax.
>
> Bence
>
>
>
> Nino.Martinez wrote:
>
>> Yeah I can confirm what Daniel are saying.. I have the same approach..
>> On the otherhand if it's an ajax link you'll need to add all the
>> components you want rerendered.
>>
>> Daniel Stoch wrote:
>>
>>> Hi,
>>>
>>> But what exactly not work?
>>>
>>> I'm using a Link with onClick() code:
>>> getSession().setLocale(locale);
>>> to swicth current locale and everything works ok. All page components
>>> are localized correctly.
>>>
>>> I think this setResponsePage(this.getPage()); call in your code is
>>> not necessary:
>>> @Override
>>> public final void onClick() {
>>> Locale locale = new Locale("en");
>>> this.getSession().setLocale(locale);
>>> setResponsePage(this.getPage());
>>> }
>>>
>>>
>>>
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>>
>
>
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by btakacs <ta...@gmail.com>.
Hi
Yeah, I understand that it is working with Ajax. But first I wanted to make
it without ajax. Later I can upgrade.
I don't know yet how can I ajaxify my pages, and this should work without
ajax.
Bence
Nino.Martinez wrote:
>
> Yeah I can confirm what Daniel are saying.. I have the same approach..
> On the otherhand if it's an ajax link you'll need to add all the
> components you want rerendered.
>
> Daniel Stoch wrote:
>> Hi,
>>
>> But what exactly not work?
>>
>> I'm using a Link with onClick() code:
>> getSession().setLocale(locale);
>> to swicth current locale and everything works ok. All page components
>> are localized correctly.
>>
>> I think this setResponsePage(this.getPage()); call in your code is
>> not necessary:
>> @Override
>> public final void onClick() {
>> Locale locale = new Locale("en");
>> this.getSession().setLocale(locale);
>> setResponsePage(this.getPage());
>> }
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Localization-issue-tp19160932p19175986.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Yeah I can confirm what Daniel are saying.. I have the same approach..
On the otherhand if it's an ajax link you'll need to add all the
components you want rerendered.
Daniel Stoch wrote:
> Hi,
>
> But what exactly not work?
>
> I'm using a Link with onClick() code:
> getSession().setLocale(locale);
> to swicth current locale and everything works ok. All page components
> are localized correctly.
>
> I think this setResponsePage(this.getPage()); call in your code is
> not necessary:
> @Override
> public final void onClick() {
> Locale locale = new Locale("en");
> this.getSession().setLocale(locale);
> setResponsePage(this.getPage());
> }
>
>
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by Daniel Stoch <da...@gmail.com>.
Hi,
But what exactly not work?
I'm using a Link with onClick() code:
getSession().setLocale(locale);
to swicth current locale and everything works ok. All page components
are localized correctly.
I think this setResponsePage(this.getPage()); call in your code is
not necessary:
@Override
public final void onClick() {
Locale locale = new Locale("en");
this.getSession().setLocale(locale);
setResponsePage(this.getPage());
}
--
Daniel
On Tue, Aug 26, 2008 at 9:56 PM, btakacs <ta...@gmail.com> wrote:
>
> Hi, All
>
> The question is:
> after
> getSession().setLocale(locale);
> running and successfully changing the locale (I checked in debug mode)
>
> when running
> setResponsePage(this.getPage());
> why the locale changes does not apply to the components?
>
> They apply only after I click on a bookmarkable link.
>
> Now it does not seem to be a Localization issue: it's some kind of reload
> issue...
>
> Any tips?
>
> Thanks:
> Bence
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Localization issue
Posted by btakacs <ta...@gmail.com>.
Hi, All
The question is:
after
getSession().setLocale(locale);
running and successfully changing the locale (I checked in debug mode)
when running
setResponsePage(this.getPage());
why the locale changes does not apply to the components?
They apply only after I click on a bookmarkable link.
Now it does not seem to be a Localization issue: it's some kind of reload
issue...
Any tips?
Thanks:
Bence
--
View this message in context: http://www.nabble.com/Localization-issue-tp19160932p19169188.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org