Tuesday, 14 May 2013

What is Theme module in GWT?

Module Logical Name Module Definition Contents
Chrome com.google.gwt.user.theme.chrome.Chrome Chrome.gwt.xml Style sheet and images for the Chrome theme.
Dark com.google.gwt.user.theme.dark.Dark Dark.gwt.xml Style sheet and images for the Dark theme.
Standard com.google.gwt.user.theme.standard.Standard Standard.gwt.xml Style sheet and images for the Standard theme.

GWT also provides several theme modules which contain default styles for widgets and panels. You can specify one theme in your project's module XML file to use as a starting point for styling your application, but you are not required to use any of them.

Deffered Binding in GWT

Deffered Binding :-Compile time create many version. and load on version according to version.

Deferred Binding Using Replacement
    <module>

      <!--  ... other configuration omitted ... -->

      <!-- Fall through to this rule is the browser isn't IE or Mozilla -->
      <replace-with class="com.google.gwt.user.client.ui.impl.PopupImpl">
        <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl"/>
      </replace-with>

      <!-- Mozilla needs a different implementation due to issue #410 -->
      <replace-with class="com.google.gwt.user.client.ui.impl.PopupImplMozilla">
        <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl" />
        <any>
          <when-property-is name="user.agent" value="gecko"/>
          <when-property-is name="user.agent" value="gecko1_8" />
        </any>
      </replace-with>

      <!-- IE has a completely different popup implementation -->
      <replace-with class="com.google.gwt.user.client.ui.impl.PopupImplIE6">
        <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl"/>
        <when-property-is name="user.agent" value="ie6" />
      </replace-with>
    </module>
   
    Deferred binding using Genrator

What is standard module in GWT?

Standard Modules GWT 1.5

Module Logical Name Module  Definition Contents
User com.google.gwt.user.User User.gwt.xml Core GWT functionality
HTTP com.google.gwt.http.HTTP HTTP.gwt.xml Low-level HTTP communications library
JSON com.google.gwt.json.JSON JSON.gwt.xml JSON creation and parsing
JUnit com.google.gwt.junit.JUnit JUnit.gwt.xml JUnit testing framework integration
XML com.google.gwt.xml.XML XML.gwt.xml XML document creation and parsing

Generally, you want to inherit at least the User module. The User module contains all the core GWT functionality, including the EntryPoint class. The User module also contains reusable UI components (widgets and panels) and support for the History feature, Internationalization, DOM programming, and more.


User.gwt.xml
<module>
   <inherits name="com.google.gwt.animation.Animation"/>
   <inherits name="com.google.gwt.canvas.Canvas"/>
   <inherits name="com.google.gwt.core.Core"/>
   <inherits name="com.google.gwt.debug.DebugBase"/>
   <inherits name='com.google.gwt.dom.builder.DomBuilder'/>
   <inherits name="com.google.gwt.editor.Editor" />
   <inherits name="com.google.gwt.event.Event"/>
   <inherits name="com.google.gwt.geolocation.Geolocation" />
   <inherits name="com.google.gwt.i18n.I18N"/>
   <inherits name="com.google.gwt.layout.Layout"/>
   <inherits name="com.google.gwt.media.Media"/>
   <inherits name="com.google.gwt.resources.Resources"/>
   <inherits name="com.google.gwt.safecss.SafeCss" />
   <inherits name="com.google.gwt.safehtml.SafeHtml" />
   <inherits name="com.google.gwt.storage.Storage" />
   <inherits name="com.google.gwt.text.Text"/>
   <inherits name="com.google.gwt.touch.Touch"/>
   <inherits name="com.google.gwt.uibinder.UiBinder"/>
   <inherits name="com.google.gwt.user.AsyncProxy"/>
   <inherits name="com.google.gwt.user.CaptionPanel" />
   <inherits name="com.google.gwt.user.cellview.CellView"/>
   <inherits name="com.google.gwt.user.ClippedImage"/>
   <inherits name="com.google.gwt.user.datepicker.DatePicker"/>
   <inherits name="com.google.gwt.user.DocumentMode"/>
   <inherits name="com.google.gwt.user.DocumentRoot" />
   <inherits name="com.google.gwt.user.DOM"/>
   <inherits name="com.google.gwt.user.FileUpload"/>
   <inherits name="com.google.gwt.user.Focus"/>
   <inherits name="com.google.gwt.user.Form"/>
   <inherits name="com.google.gwt.user.History"/>
   <inherits name="com.google.gwt.user.HTTPRequest"/>
   <inherits name="com.google.gwt.user.Hyperlink"/>
   <inherits name="com.google.gwt.user.ImageBundle"/> 
   <inherits name="com.google.gwt.user.Popup"/>
   <inherits name="com.google.gwt.user.RemoteService"/>
   <inherits name="com.google.gwt.user.ResizeLayoutPanel"/>
   <inherits name="com.google.gwt.user.RichText"/>
   <inherits name="com.google.gwt.user.Scroll"/>
   <inherits name="com.google.gwt.user.SplitPanel"/>
   <inherits name="com.google.gwt.user.TextBox"/>
   <inherits name="com.google.gwt.user.Tree"/>
   <inherits name="com.google.gwt.user.Window" />
   <inherits name="com.google.gwt.widget.Widget"/>

   <super-source path="translatable"/>
   <source path="client"/>
</module>


What is logical name of a module?

For com.ashish.GWTExample.gwt.xml, logical name will bw com.ashish.GWTExample

What configuration we write in modulename.gwt.xml?

  1. inherited modules 
  2. entry point class
  3. source path entry, public path entry
  4. deferred binding rules, including property providers and class generators

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='gxtexample'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Other module inherits                                      -->

  <!-- Specify the app entry point class.                         -->
  <entry-point class='com.gxt.client.GXTExample'/>
  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>

</module>

why we use module rename-to in modulename.gwt.xml?

in GWT application, logical name of module is large like com.ashish.gwtExample. If i have to use this name anywhere like in web.xml then it is complicated name. So we can short this name using rename-to like gwtExample.

<module rename-to='gxtexample'>
</module>

What source path we provide in modulename.gwt.xml? and why?

It is path for client and shared.
<source path='client'/>
  <source path='shared'/>


source path is used to tell GWT compiler that which package code, we need to convert into  javascript. We do not entry of server package becoz we do not convert it into javascript.