8.8. Inheriting Other Modules
I changed the module XML file for this application in order to use the JSON- and i18n-related modules that the GWT provides. The reason? I used the JSON module to handle the JSON return value from the PHP file. In addition, I used an interface from a module called com.google.gwt.i18n.I18N, so that the application can optionally display its messages in Spanish or German.
<module> <!-- Inherit the core Web Toolkit stuff. --> <inherits name='com.google.gwt.user.User'/> <inherits name="com.google.gwt.json.JSON"/> <inherits name="com.google.gwt.i18n.I18N"/> <extend-property name="locale" values="es"/> <extend-property name="locale" values="de"/> <extend-property name="locale" values="es_ES"/> <extend-property name="locale" values="de_DE"/> <!-- Specify the app entry point class. --> <entry-point class='com.parkerriver.gwt.intro.client.GwtAjax'/> </module>
Inheriting com.google.gwt.user.User is standard for most GWT applications. If you want to use the JSON and i18n classes, then include the additional XML elements that the prior code sample shows.
What are the extend-property elements? These are elements indicating that the application will handle two locales other than the default en_US. A locale designates the language that a web page will use, as well as formatting techniques such as for monetary values used in specific countries or regions.
A locale is made up of a language code, optionally followed by an underscore character and a country code. So en_US refers to English as spoken in the United States; de_DE represents German as spoken in Germany (remember, other countries such as Switzerland also speak German). An upcoming section describes how to handle these locales in your application. First I will show the JSON-related code.