GWT动态区域设置 [英] GWT Dynamic Locale

查看:119
本文介绍了GWT动态区域设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Spring LocaleContextHolder 的帮助下设置 gwt-locale 以用户选择的语言环境。

  public static final String getCurrentLocale(){
return LocaleContextHolder.getLocale()。getLanguage();
}

实际上,Spring MVC中的登录界面和 gwtp 。同样的locale用户在登录之前必须在外部界面中选择

不幸的是,我没有看到任何gwt内置的Locale setter。
$ b

我的 X.gwt.xml 的默认区域设置为 kh 是:








 < inherits name =com.google.gwt.uibinder.UiBinder/> 
<继承名称=com.google.gwt.inject.Inject/>
<继承名称=com.gwtplatform.mvp.Mvp/>
< inherits name =gwtquery.plugins.droppable.Droppable/>

< source path =client/>
< source path =shared/>

< define-configuration-property name =gin.ginjectoris-multi-valued =false/>
< set-configuration-property name =gin.ginjectorvalue =com.prayagupd.client.mvp.XGInjector/>
< set-configuration-property name =UiBinder.useSafeHtmlTemplatesvalue =true/>

< extend-property name =localevalues =kh/>
< extend-property name =localevalues =en/>
< set-property name =localevalue =kh/>
< set-property-fallback name =localevalue =kh/>

< entry-point class =com.prayagupd.client.XEntryPoint/>



我的 XEntryPoint.java 读作:

  public class XEntryPoint implements EntryPoint {

private final IUserServiceAsync rpc = GWT.create(IUserService.class);

@Override
public void onModuleLoad(){
//
rpc.getLocale(new AsyncCallback< String>(){

@Override
public void onSuccess(String locale){
GWT.log(Locale From Spring:+ locale);
GWT.log(Locale From GWT:+ LocaleInfo.getCurrentLocale ().getLocaleName());
//这里我想设置语言环境为gwt
//类似GWTLocale.setLocale(locale);
}

@Override
public void onFailure(Throwable caught){
GWT.log(caught.getMessage());
}
});
DelayedBindRegistry.bind(ginjector);
ginjector.getPlaceManager()。revealCurrentPlace();




home.jsp for gwt-loading

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Strict // ENhttp ://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> 

<%@ tag import =java.util.Calendar%>
<%@ tag body-content =scriptless%>
<%@ taglib prefix =springuri =http://www.springframework.org/tags%>
<%@ taglib prefix =formuri =http://www.springframework.org/tags/form%>
<%@ taglib prefix =curi =http://java.sun.com/jsp/jstl/core%>
<%@ taglib prefix =sprtagdir =/ WEB-INF / tags%>
<%@ attribute name =isgwtrequired =truetype =java.lang.Boolean%>


<! - <!DOCTYPE html> - >
< html xmlns =http://www.w3.org/1999/xhtml>
< head>

< link rel =shortcut icontype =image / pnghref =/ images / favicon.png/>
< script type =text / javascriptsrc =js / reload.captcha.js>< / script>
< script type =text / javascriptsrc =js / date.picker.js>< / script>
< link rel =stylesheethref =/ styles / innerstyle.csstype =text / css/>

< c:if test =$ {not isgwt}>
< link rel =stylesheethref =/ styles / mainstyler.csstype =text / css/>
< script type =text / javascriptsrc =js / modernizer.custom.js>< / script>

< script type =text / javascriptsrc =js / jquery.js>< / script>
< script type =text / javascriptsrc =js / jquery-ui-custom.min.js>< / script>
< script src =js / jquery.thumbnailScroller.js>< / script>
< / c:if>
< c:if test =$ {isgwt}>
< meta name =gwt:propertycontent =locale = $ {locale}>
< script type =text / javascriptlanguage =javascriptsrc =upd / upd.nocache.js>< / script>
< / c:if>

< script type =text / javascript>
$(window).load(function(){
$('#slider')。nivoSlider();
});
< / script>

< title>< c:out value =$ {locale}>< / c:out>< spring:message code =page.header/><< ; /标题>
< / head>
< body>
< c:when test =$ {empty username}>
< div class =header_con>
< div class =header_in>
< spr:header />
< spr:login />
< div class =clear>< / div>
< / div>

< div class =main_con>
< jsp:doBody />
< spr:footer />
< / div>
< div class =clear>< / div>
< / div>
< / c:当>
< c:其他>
< div id =mainHolder>
< div id =wrapper>
< spr:headerInner />