Monday, April 29, 2013

Prevent Default Refresh Event in Browser Using GWT

Bit odd requirement that if anyone need to prevent default Cntrl + R or F5 event using GWT (Google Web Tool Kit). It can be done easily. In onModuleMethod of EntryPoint class just use this code.

public void onModuleLoad() {
      //disable refresh button
  Event.addNativePreviewHandler(new NativePreviewHandler() {

   public void onPreviewNativeEvent(NativePreviewEvent event) {
    switch (event.getTypeInt()) {
    case Event.ONKEYDOWN:
     NativeEvent nEvent = event.getNativeEvent();
     if (nEvent.getCtrlKey() && nEvent.getKeyCode() == 'R') {

     if (nEvent.getKeyCode() == 116) {


This will full fill the need across the GWT application. Reference : Co worker : Ruhul

No comments:

Post a Comment