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


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

This annotation can be used to expose a class as a Crux controller.

Controller classes can be refereed from a view page (.crux.xml and .view.xml files) and contain the methods used to handle events triggered by the user interface (the pages).

For example, see the following controller:

 @Controller("myController")
 public class MyController
 {
    @Expose
    public void myEventHandler()
    {
        Window.alert("event dispatched!");
    }
 }
 

It can be used inside a .crux.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.myEventHandler" text="My Button" ></g:button>
     </body>
  </html>
 
On the previous example, the controller myController is imported into the screen (through the <c:screen> tag) and the method myEventHandler of this controller is associated with click events of the widget myButton.

Author:
Thiago da Rosa de Bustamante
See Also:
Expose, Inject

Required Element Summary
 String value
          The name associated with the controller.
 
Optional Element Summary
 boolean lazy
          If this property is true, the controller is only instantiated by Crux engine when it is first required to handle an event.
 boolean stateful
          A Statefull controller keeps its state between two controller calls.
 DeviceAdaptive.Device[] supportedDevices
          You can choose to use the annotated class only for a restricted list of devices.
 

Element Detail

value

public abstract String value
The name associated with the controller. This name is used on .crux.xml and .view.xml pages to identify the controller.

stateful

public abstract boolean stateful
A Statefull controller keeps its state between two controller calls. If this property is true, the same instance of controller class will be used to handle all events. If false a new instance will be created for any event triggered.

Default:
true

lazy

public abstract boolean lazy
If this property is true, the controller is only instantiated by Crux engine when it is first required to handle an event.

Default:
true

supportedDevices

public abstract DeviceAdaptive.Device[] supportedDevices
You can choose to use the annotated class only for a restricted list of devices. This allow you to create two different classes using the same controller name, but one target a collection of devices and the other targets a different collection.

Default:
org.cruxframework.crux.core.client.screen.DeviceAdaptive.Device.all


Copyright © 2014. All rights reserved.