Section 8.8. Inheriting Other Modules


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.

Remember that all of the Java classes that you are writing for the client side of the Ajax application will eventually be converted to their corresponding JavaScript. Therefore, when your project's module inherits another module, what you are really doing is importing the JavaScript that other developers have created. The GWT provides modules that handle the JSON format and i18n programming, among others. Here is what our altered module looks like (in GwtAjax.gwt.xml):

 <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.




Google Web Toolkit for Ajax
Google Web Toolkit GWT Java AJAX Programming: A step-by-step to Google Web Toolkit for creating Ajax applications fast
ISBN: 1847191002
EAN: 2147483647
Year: 2006
Pages: 29

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net