Thursday, 12 October 2017

How to retrieve Client's Timezone in GWT

  • Let say Application is hosted at one place whose time zone is 'A'
  • User can login any where from the world whose time zone is 'B'
  • So the server where the application is hosted should know the time zone of the user access
To retrieve the client browser time zone ,use GWT DateTimeFormat

 DateTimeFormat.getFormat("ZZZZ").format(new Date())

The above method will give the browser time zone.

There is one more way to retrieve the time zone is to use JSNI

private native int getClientOffsetTimeZone() /*-{
    return new Date().getTimezoneOffset();
}-*/;

Note that the getTimezoneOffset() method returns the time difference between UTC time and local time in minutes,
For example,
 If your time zone is GMT+2, -120 will be returned
 If your time zone is GMT-2, +120 will be returned

Monday, 22 February 2016

Coder Vs Programmer

Coder:


Coder is some one who does a routine job and works very hard. Even works as per the client requirements and meets the deadline.Coder will follow the instruction and guidelines blindly.
Will use lot of If else statement Without using any design patterns .


Programmer:


Programmer is the one who works very smart. Programmer works in a best possible way to deliver the client requirement. Programmer will not work blindly. Will use Design patterns and principles with new innovative thoughts.Be a programmer not a coder.

This is sample Video which explains about the difference between Coder Vs Programmer (which is taken from youtube).




Tuesday, 9 February 2016

GWT Tutorial:: FAQ on Module Descriptor

GWT Module Descriptor:

GWT Module is a configuration file which is used to configure the GWT application.
It contain with the file extension *.gwt.xml.
* is the name of the application and this file should be reside inside the project's root.
For Example If the project name is MyApp then the Module name will be MyApp.gwt.xml.

Below is the sample example which will explain about the Module Descriptor,

<?xml version="1.0" encoding="utf-8"?>
<module rename-to='MyApp'>
   <!-- inherit the core web toolkit stuff.  -->
   <inherits name='com.google.gwt.user.user'/>

   <!-- inherit the default gwt style sheet. -->
   <inherits name='com.google.gwt.user.theme.clean.Clean'/>

   <!-- specify the app entry point class. -->
   <entry-point class='com.example.client.MyApp'/>

   <!-- specify the paths for translatable code (the below folders get complied to JS)  -->
   <source path='client'/>
   <source path='shared'/>

   <!-- specify the paths for static files like html, css etc. -->
   <public path='...'/>
   <public path='...'/>

   <!-- specify the paths for external javascript files -->
   <script src="js-url" />
   <script src="js-url" />

   <!-- specify the paths for external style sheet files  -->
   <stylesheet  src="css-url" />
   <stylesheet  src="css-url" />

</module>


Even More then one entry point class can be defined in Module Descriptor which will be executed one by one.
GWT provides this default themes
<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"/>

Thursday, 27 August 2015

Reduce Compilation time for GWT 2.5

A ‘normal’ build is one where you get 6 basic permutations, one for each category of browser. These have been selected by the GWT team as related enough to always treat as the same.
These browsers are:

·         Firefox, all versions
·         All Webkit browsers (Safari, Chrome, Android Browser, etc)
·         IE6 and IE7
·         IE8
·         IE9 (and IE10)
·         Opera9

It is possible to collapse all properties to decrease the amount of time spend compiling a module for testing/development purposes by adding the following:

<collapse-all-properties />

Which result in taking less time for compilation , no matter how many permutations you had configured before this line, only one file will be created. This is especially handy for very fast builds or cases where you want to keep the build size small but still it will works for all the browser which we have configured.


Monday, 20 April 2015

Classic Dev Mode(GWT) Will not support in Latest Chrome Browser

As per the GWT Announcements (Release note 2.6),
  •  GWT Development Mode will no longer be available for Chrome sometime in 2014, so we improved alternate ways of debugging. There are improvements to Super Dev Mode, asserts, console logging, and error messages.
  • So Lunching the Application in Chrome Newer Version with Classic Dev Mode is Disabled, because they have disabled NPAPI Plug-in in Chrome Newer Version. Now it’s time to use Super Dev Mode.
SuperDev mode as default in GWT 2.7:

The Main feature in GWT 2.7 is SuperDev mode(SDM), with Dev mode now deprecated. You use the browser’s built in debugger and don’t need to use any browser plugins. With SDM, all of your debugging happens right inside your browser, making it easier to debug mixed Java/Javascript code. If you are familiar with Super Dev Mode in 2.6, you will also notice that you no longer need any bookmarklets to enable/recompile when using Super Dev Mode, the code is recompiled automatically when you reload the page.


Other Workaround to Launch the Apps in Chrome Newer Version With Classic Dev Mode is to Enable NPAPI Flag, Follow the Below Steps
 
1.Open New Tab and Enter chrome://flags/#enable-npapi
 
2.Enable this Enable NPAPI Mac, Windows
 
3.Then bottom of the page click "Relunch" button.
 
**NPAPI  is scheduled to be removed from Chrome(version 45) in September 2015 and this workaround will be supported up to chrome 44 version only.

Saturday, 18 April 2015

Interface Versus Abstract Classes

Difference Between Interface and Abstract Class:
Interface
Abstract Class
1.       If we don’t know anything about implementation just we have requirement specification, then we can use Interface
If we know partial Implementation(not full) then we can use Abstract Class.
2.       Every Method in interface is public abstract, that why interface is Pure abstract class (100%).
In addition to the abstract method Abstract class can also have Non abstract Method(concrete method).
3.       Methods in interface are public and abstract modifiers we can’t use private,protected,final,static,synchronized,native and strictfp modifiers.
There is no restriction for Methods modifiers in  Abstract class.
4.       By Implicitly, variable in interface will be public static final.
In abstract class the variable can be of any data types.
5.       Since variables in interface is public static final we can’t use as private or protected ,transient or volatile modifiers.
There is no restriction for Variable in Abstract class
6.       We should assign the value to variable at the time of declaration otherwise compiler will give error. public static final int x=3;
There is no such restriction in Abstract class.
7.       We can’t declare any instance or static method inside the interface.
Can have instance or static method inside the abstract class.
8.       We can’t have constructor inside the interface, since the variable is static
We can have constructor inside the Abstract class.
9.       Interface can extend more than one interface, Interface C extends A,B
Abstract class can extend class or Abstract class
10.   Interface Car{
public static final int x=10;
public int speed();
}
abstract class Engine{                                                                    public abstract void engineType(String carType);
 public String engineColor(){          return "red";                                           }



Tuesday, 24 March 2015

Custom Widget in GWT

GWT Provides ways to create Custom User Interface.They are 3 ways to Create Custom Widgets which are listed below.

  1. By Extending Composite Class
  2. Wrap JavaScript inside Widget using JSNI
  3. Creating Widget from Scratch Using GWT DOM API.

By Extending Composite Class:
               The most effective way of creating custom widget is by extending composite class.Create a class which extend composite class and pass the constructed widget inside the initWidget() Method. 
For Example:
 Creating a TextField component like TextBox with Label

 public class TextField extends Composite{
     public TextField(){

       HorizontalPanel panel=new HorizontalPanel(); // to Create HorizontalPanel

        Label lbl=new Label();    //to Create Label
        lbl.setText("NAME");     

       TextBox box=new TextBox();  //to Create TextBox

        panel.add(lbl);     //Add label into HorizontalPanel
        panel.add(box);    //Add textbox into HorizontalPanel

        initWidget(panel);      //Pass the HorizontalPanel into initWidget of Composite Class

}
}
Which gives the Custom Widget see the Screen Shot
Custom Widget:TextField Component



Wrapping JavaScript into Widget Using JSNI:
This is the one more approach to create custom widget, Use JavaScript and Wrapped inside into GWT Component using Java Script Native Interface(JSNI).
Syntax for JSNI:
public static native void customWidget()/*-{
           //JavaScript Code
  }-*/; 

Creating Widget from Scratch Using GWT DOM API:
This is the third approach to create custom widget , using Java code from Scratch it is some what trickier since it has be created from lower level.Many of the GWT Basic widgets are written by using  this approach like TextBox,Button.

Finally,Its recommanded and most effective way to create custom widget is by extending Composite Class.









CSS Selectors

  CSS Selectors In CSS, selectors are patterns used to select the element(s) you want to style There are 3 different types of CSS selectors ...