org.cruxframework.crux.core.client.controller
Annotation Type Global


@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface Global

This annotation can be used to give a Global scope to a controller. It only makes any effect if used on a Controller class.

A Global controller does not need to be imported on a screen to be used. All application views will automatically import the controller.

For example:

 @Global
 @Controller("myController")
 public class MyController
 {
    @Expose
    public void myEventHandler()
    {
        Window.alert("event dispatched!");
    }
    
    //Only can handle click events 
    @Expose
    public void myClickEventHandler(ClickEvent event)
    {
        Window.alert("event dispatched!");
    }
 }
 

It can be used on a .crux.xml or .view.xml page, as illustrated by the following example:

 <html 
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:c="http://www.cruxframework.org/crux"  
  xmlns:g="http://www.cruxframework.org/crux/gwt">
     <body>
        <g:button id="myButton" onClick="myController.myClickEventHandler" 
            onDoubleClick="myController.myEventHandler" text="My Button" ></g:button>
     </body>
  </html>
 
NOTE: Only use this annotation when needed. Using this indiscriminately, can decrease the performance, spending unnecessary memory on client.

Author:
Thiago da Rosa de Bustamante
See Also:
Controller



Copyright © 2014. All rights reserved.