You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by mirko kleiner <mi...@yahoo.com> on 2004/11/26 11:03:11 UTC
changing locale/language by calling activateExternalPage
Hi
I'm searching for a solution to set language/locale of
my application by calling activateExternalPage?-This
is necessary, because our client wants to decide in
which language the application should be loaded.
I've tried to work it out but it wont work properly.
I'm using PageCallback to reset locale is this the
right way?
Please have a look to my code:
visit class:
private ICallback callback;
public void setCallback(ICallback callbackPage) {
this.callback = callbackPage;
}
public void callback(IRequestCycle cycle) {
callback.performCallback(cycle);
}
page class implements PageRenderListener,
IExternalPage:
public void pageBeginRender(PageEvent arg0) {
Visit visit = (Visit) getVisit();
visit.setCallback(new
PageCallback(getPage()));
....
}
/**
* Get the URL parameter by external call, parse
them and execute the
* correct method according to the parameter(s).
*
* Example of a call forcing a language change of
the current page:
* http://.../app?service=external/Search&sp=Sde
*/
public void activateExternalPage(Object[]
parameters, IRequestCycle cycle) throws
PageRedirectException {
if (parameters.length == 1) {
//call method to force language change and
pass on the parameter
doLanguageChange(parameters[0].toString());
}
}
/**
* Performs a locale change by doing a callback to
this page's first request
* which has been stored in the visit object.
*
* @param lang selected language
* @see
http://article.gmane.org/gmane.comp.java.tapestry.user/13796/match=+change+locale+page
*/
public void doLanguageChange(String lang) {
Visit visit = (Visit) getVisit();
Locale locale = new Locale(lang);
if
(!locale.equals(getPage().getEngine().getLocale())) {
//set this page's new locale
getPage().getEngine().setLocale(locale);
//perform a callback
visit.callback(getRequestCycle());
}
}
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org