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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to