The Task Framework  

Introduction to the Tasks Framework

Tasks are functional units that accomplish a business operation in your application. The task framework provides an easy and systematic way of writing and executing custom tasks. A set of tasks are shipped with the Web ADF they are:

The above tasks are configurable from the Manager application when you create a new web application. The usage of these tasks does not require any programming knowledge.

The Web ADF provides a framework to write custom tasks. Some of the advantages of using the task framework are,

For information on how to configure and work with the pre-built task refer to documentation of the Manager application.

For information on how to write custom tasks refer to the section titled Writing a Custom Task

Task Framework
The task framework provides an easy way to write custom functionality in the form of tasks. Tasks are simple Java classes that follow conventions similar to JavaBean. The task framework introspects these classes and generates the necessary metadata information for providing the relevant html elements to interact with the task. It is possible to override the default introspection behavior by providing custom metadata information. The framework is versatile enough to generate the metadata for your tasks that enables you to concentrate just on the functionality you are implementing. It also provides a way to specify custom metadata information to have control over fine grained details like using images for buttons and choosing different layouts for your task inputs.

Task Inputs
A task consists of three types of input elements parameters, commands and tools. The method signature in your java class determines the type of input.

Task Results
Most of the time the tasks generate some results. The results could be from a spatial query, geocoding, or results from a geo-processing operation. The task framework can work work with any arbitrary Java object as results. The task results support three types of information on them. They are

By default, the task results are visualized in the form of a tree. The framework supports representation of the results in other forms also. The diagram below shows the task result items as they are visualized in a Web application.

Task results

Task Visualization
The task framework by default, provides a simple html representation of the inputs in your tasks. More sophisticated html representation can be achieved by providing additional information in the TaskInfo class. You have already seen a TaskInfo class earlier that was used to describe the tool descriptors for a tool. The framework also supports three layout types: default, absolute, and tabular.

  public class DemoTaskInfo extends SimpleTaskInfo {
  private Class taskClass = DemoTask.class;
  private TaskDescriptor taskDesc = null;
  private TabularLayout[] taskLayout = null;
  taskprivate TaskParamDescriptor[] taskParams = null;
  private TaskToolDescriptor[] taskTools = null;
  private TaskActionDescriptor[] taskActions = null;

  public DemoTaskInfo() {
    this.taskDesc = new TaskDescriptor(this.taskClass, "DemoTask", "Demo Task");

    this.taskParams = new TaskParamDescriptor[1];
    this.taskParams[0] = new TaskParamDescriptor(this.taskClass, "name", "City Name");

    this.taskTools = new TaskToolDescriptor[1];
    this.taskTools[0] = new TaskToolDescriptor(this.taskClass, "myTool", "Sample Tool", "EsriMapRectangle");

    this.taskActions = new TaskActionDescriptor[1];
    taskActions[0] =  new TaskActionDescriptor(this.taskClass, "myCommand", "Action");
    toolDescs[0].setToolTip("Select by Rectangle");
    this.taskLayout = new TabularLayout[1];
    this.taskLayout[0] = new TabularLayout();
    this.taskLayout[0].addComponent(taskParams[0], new TabularLayout.TabularPosition(0, 0, 0, 4));
    this.taskLayout[0].addComponent(taskParams[1], new TabularLayout.TabularPosition(1, 1, 0, 4));
    this.taskLayout[0].addComponent(taskParams[2], new TabularLayout.TabularPosition(2, 2, 0, 4));
    this.taskLayout[0].addComponent(taskParams[3], new TabularLayout.TabularPosition(3, 3, 0, 4));
    this.taskLayout[0].addComponent(taskTools[0], new TabularLayout.TabularPosition(4, 0, 0, 0));
    this.taskLayout[0].addComponent(taskActions[0], new TabularLayout.TabularPosition(4, 1, 0, 0));
    this.taskLayout[0].addComponent(taskActions[1], new TabularLayout.TabularPosition(4, 2, 0, 0));

  public TaskDescriptor getTaskDescriptor() {
    return this.taskDesc;

  public TaskLayout[] getTaskLayout() {
    return this.taskLayout;

  public TaskParamDescriptorModel[] getParamDescriptors() {
    return this.taskParams;

  public TaskToolDescriptorModel[] getToolDescriptors() {
    return this.taskTools;

  public TaskActionDescriptorModel[] getActionDescriptors() {
    return this.taskActions;