GWT <replace-with> not working

风格不统一 提交于 2019-12-10 11:39:56

问题


I am trying to use a custom implementation of LocaleInfoImpl in GWT. For this I created a class CustomLocaleInfo and in my .gwt.xml file like this:

  <replace-with class="my.package.util.CustomLocaleInfo">
      <when-type-is class="com.google.gwt.i18n.client.impl.LocaleInfoImpl" />
  </replace-with>

My class:

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();
                }
            };
        }

}

Even if I use random names, the compiler does not throw an error.

I am using GWT 2.8.1. Please advise!

EDIT:

My main app .gwt.xml file:

  <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"/>

The MyBaseModule lookes like this:

<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"/>

来源:https://stackoverflow.com/questions/51819228/gwt-replace-with-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!