Hi,

I want a language switcher in my GWT app.
So, I setup an Anchor and add it to RootPanel:

        Anchor lnkRU=new Anchor();
        lnkRU.setText("RU");
        lnkRU.setHref("");
        lnkRU.addClickHandler(new ClickHandler() { @Override public
void onClick(ClickEvent event) { changeLocale("ru"); } });
        RootPanel.get("con").add(lnkRU);

And in the attached eventhandler I am modifying the url by replacing
or adding the hlocale=xx parameter to url:

    private native void changeLocale(String newLocale)/*-{
         //alert("Language changed to : "+newLocale);
         var currLocation = $wnd.location.toString();
         //alert("currLocation : "+currLocation);

         // remove hlocal parameter if any
         var newurl=currLocation.replace
(/&hlocale=[a-zA-Z_]{2,}/g,"").replace
(/\?hlocale=[a-zA-Z_]{2,}/g,"");
         // add new hlocale
         if (newurl.match (/\?/)) newurl+="&hlocale="+newLocale;
         else newurl+="?hlocale="+newLocale;
         //alert ("newurl="+newurl);

         $wnd.location.replace(newurl);
    }-*/;

The newurl is correct before calling $wnd.location.replace(newurl),
but the page simply reloads with OLD url.
After reload no hlocale=xx in address bar.

Why?


Victor.


--
Victor Papp
skype: victorpapp
Tek. +38 050 5 141 142

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to