Custom Task Guide

Custom Task Guide

Step 3. Create the BeanInfo XML

Step 3. Create the BeanInfo XML

The BeanInfo file is a simple XML file that provides additional information needed by the task at project design time, by the Project Designer.  The project designer generates a screen for your task based on the information from the bean info. You can define the following information in the bean info:
  1. Labels for various attributes of the task. For example, you can define a nice label, “Source File”, for the “sourceFile” attribute.
  2. Descriptions or help text for various attributes of the task.
  3. The field type for attributes (e.g. text field, text area, file, directory etc.)
  4. Define whether an attribute is required or not so the project designer can decorate the field as required using the standard convention (typically a red asterisk after the field label)
  5. Any fixed options that an attribute supports, which will be listed in a drop-down field.
  6. Indicating the default values for attributes, if any.
    For detailed field and element information that can be used in the bean, see Field Types and Elements.
    The BeanInfo XML must exist in the same package as the corresponding Task (or any other project component). The name of the file must be same as the class name of the project component, followed by BeanInfo.xml. For our CopyTask, the BeanInfo must be defined in com.example.CopyTaskBeanInfo.xml.
    Listed below is the bean info for our Copy Task:
    <?xml version="1.0" encoding="UTF-8" ?> <projectComponent name="CopyTask"> <label>Example Copy Task</label> <description>A simple task for copying a file from one directory to another. </description> <tabPanel name="main"> <tab name="basic"> <attribute name="sourceFile"> <label>Source File</label> <description>Specify the file to copy. </description> <fieldType>localOrNetworkFile</fieldType> <required>true</required> <cols>60</cols> </attribute> <attribute name="destinationDirectory"> <label>Destination Directory</label> <description>Specify the directory to which the source file should be copied. </description> <fieldType>localOrNetworkDirectory</fieldType> <required>true</required> <cols>60</cols> </attribute> </tab> <tab name="control" /> <tab name="onError" /> </tabPanel> </projectComponent>
    The BeanInfo must start with a root element of <projectComponent>. The name of the project component can be anything, but is recommended to keep the same as the class name. Define label and description for the project component using the <label> and <description> tags.
    The Project Designer organizes various attributes of a project component into tabs. Tabs are defined inside a <tabPanel>. Tabs will have a name, label and description. For our copy task, we defined the sourceFile and destinationDirectory attributes under the Basic tab. We then indicated that we want to show the standard Control and On Error tabs that are shared by all tasks. We have defined the field type for the source file as localOrNetworkFile, which will render a Browse button next to the text field so the user can browse the local and network files.

0 COMMENTS

We’d like to hear from you!