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


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

This annotation can be used to expose a controller method as an factory 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 a factory:

1) Be annotated with @Factory annotation.

2) Have public visibility.

3) Have only one parameter (The factory input).

4) Return a value (not void). This is the factory output.

For example:

 @Controller("myController")
 public class MyController
 {
    @Factory
    public Label myWidgetFactory(Person person)
    {
        return new Label(person.getName());
    }
 }
 

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">
  xmlns:faces="http://www.cruxframework.org/crux/smart-faces"
     <body>
        <c:screen useController="myController" useDataSource="personDS" />
          <faces:widgetList dataSource="personDS" id="people" autoLoadData="true" pageSize="20" width="100%" height="100%">
               <faces:widgetFactoryOnController onCreateWidget="myController.myWidgetFactory"/>
          </faces:widgetList>
     </body>
  </html>
 

Author:
Thiago da Rosa de Bustamante
See Also:
Controller



Copyright © 2014. All rights reserved.