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


@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface Expose

This annotation can be used to expose a controller method as an event handler method. It only makes any effect if used on methods of a Controller class.

Methods annotated with this annotation can be refereed on .crux.xml and .view.xml pages. A method must obey the following constraints to be exposed as an event handler:

1) Be annotated with @Expose annotation.

2) Have public visibility.

3) Have no parameter or have only one parameter, with type equals to the type of the event handled by the method.

For example:

 @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>
        <c:screen useController="myController" />
        <g:button id="myButton" onClick="myController.myClickEventHandler" 
            onDoubleClick="myController.myEventHandler" text="My Button" ></g:button>
     </body>
  </html>
 

Author:
Thiago da Rosa de Bustamante
See Also:
Controller



Copyright © 2014. All rights reserved.