我正在尝试在GWT中使用LocaleInfoImpl的自定义实现。为此,我在如下的.gwt.xml文件中创建了一个CustomLocaleInfo类:
<replace-with class="my.package.util.CustomLocaleInfo">
<when-type-is class="com.google.gwt.i18n.client.impl.LocaleInfoImpl" />
</replace-with>
我的课:
public class CustomLocaleInfo extends LocaleInfoImpl {
@Override
public NumberConstants getNumberConstants() {
Notifier.printDebug(">>> getting number constants");
final NumberConstants nc = super.getNumberConstants();
return new NumberConstants() {
@Override
public String notANumber() {
return nc.notANumber();
}
@Override
public String currencyPattern() {
return nc.currencyPattern();
}
@Override
public String decimalPattern() {
return nc.decimalPattern();
}
@Override
public String decimalSeparator() {
return ".";
}
@Override
public String defCurrencyCode() {
return nc.defCurrencyCode();
}
@Override
public String exponentialSymbol() {
return nc.exponentialSymbol();
}
@Override
public String globalCurrencyPattern() {
return nc.globalCurrencyPattern();
}
@Override
public String groupingSeparator() {
return ",";//or any custom separator you desire
}
@Override
public String infinity() {
return nc.infinity();
}
@Override
public String minusSign() {
return nc.minusSign();
}
@Override
public String monetaryGroupingSeparator() {
return nc.monetaryGroupingSeparator();
}
@Override
public String monetarySeparator() {
return nc.monetarySeparator();
}
@Override
public String percent() {
return nc.percent();
}
@Override
public String percentPattern() {
return nc.percentPattern();
}
@Override
public String perMill() {
return nc.perMill();
}
@Override
public String plusSign() {
return nc.plusSign();
}
@Override
public String scientificPattern() {
return nc.scientificPattern();
}
@Override
public String simpleCurrencyPattern() {
return nc.simpleCurrencyPattern();
}
@Override
public String zeroDigit() {
return nc.zeroDigit();
}
};
}
}
即使我使用随机名称,编译器也不会抛出错误。
我正在使用GWT 2.8.1。请指教!
编辑:
我的主应用程序.gwt.xml文件:
<inherits name="com.sksamuel.gwt.GwtWebsockets" />
<inherits name='com.google.gwt.appengine.channel.Channel'/>
<inherits name='org.adamtacy.GWTEffects'/>
<inherits name='com.gwtsandbox.colorpicker.ColorPicker'/>
<inherits name="com.googlecode.gwt.charts.Charts"/>
<inherits name='com.googlecode.gchart.GChart'/>
<inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>
<inherits name='org.vaadin.gwtgraphics.GWTGraphics'/>
<inherits name="com.google.gwt.json.JSON" />
<inherits name="com.google.web.bindery.autobean.AutoBean"/>
<inherits name="org.moxieapps.gwt.uploader.Uploader"/>
<inherits name='...MyBaseModule'/>
<set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
<stylesheet src="res/spi.css?v4"/>
<stylesheet src="app.css?v=180321"/>
<entry-point class='.....ApplicationEntryPoint'/>
<source path='client'/>
<source path='shared'/>
<replace-with class="biz.ebas.platform.generic.client.visual.advanced.util.CustomLocaleInfo">
<when-type-is class="com.google.gwt.i18n.client.impl.LocaleInfoImpl" />
</replace-with>
<extend-property name="locale" values="ro,en,ru"/>
<collapse-property name="locale" values="*"/>
<set-property-fallback name="locale" value="en"/>
<set-property name="user.agent" value="safari,gecko1_8,ie9,ie10" />
<!-- enable the SuperDevMode book marklets -->
<add-linker name="xsiframe"/>
MyBaseModule看起来像这样:
<inherits name="com.google.gwt.user.User" />
<inherits name="com.google.gwt.json.JSON" />
<inherits name="com.google.gwt.resources.Resources" />
<stylesheet src="font-awesome-4.7.0/css/font-awesome.min.css"/>
<stylesheet src="res/lib.css?v6"/>
<stylesheet src="res/libcomp.css?v6"/>
<source path="client"/>
<source path="shared"/>
<super-source path="jre"/>