@OnDocument

This annotation is defined on the Presentation Layer.

Target: Method of a POJO annotated with @StageDefinition.

Description: Marks a method to be executed when a given document generation event is fired.

The supported return types are:

  • Bean: Will add a node called "result" with the string content
  • String: Will add a node called "result" with the string content
  • boolean: Will add a node called "result" with the boolean content
  • List: Will add a node called "result" with the array of parsed objects (parsed like normal beans or supported primitives)
  • Map: Will add an array of nodes with the key/value pairs. The keys must be Strings, and the values will be parsed like normal beans or supported primitives
  • void: Will ignore the result. The AJAX will consume any content placed in the stage results map and create the result from it.

JavaDoc: Click here

Attributes:

Name Description Data type Required Default value
value The id of the AJAX event to link to the method. String Yes -

Example:

public class SomeStage {

    // Ties the method to the OnAJAX event with the id "getRows".
    @OnAJAX("getRows")
    public Map<String, String> aMethod() {
        Map<String, String> rows = new HashMap<String, String>();

        rows.put("id1", "first row");
        rows.put("id2", "second row");
        rows.put("id3", "third row");

        return rows;
    }
}

See also:

Back to annotation reference