Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Friday, April 1, 2011

Component Field CLOSED_LIST in Talend Open Studio

If you're building a Talend Open Studio component that requires the user to select a value from a drop-down list, there are several PARAMETER FIELDS available.  One of the FIELDS, type CLOSED_LIST, will allow you to form a list of items using hardcoded strings.

The CLOSED_LIST PARAMETER is used to present a hardcoded list of values to the user when configuring a component for Talend Open Studio.  This is specified in the FIELD=CLOSED_LIST attribute of the PARAMETER element in the component's XML descriptor

XML Descriptor
 
For example, the following XML descriptor presents a drop down list of values to the user: None, Required, Max Length, Date.

XML Descriptor with a CLOSED_LIST PARAMETER
The list is defined in a nested ITEMS/ITEM structure in the PARAMETER element.  For every item to appear in the drop down, there is a NAME / VALUE pair. A default is selected by specifying the DEFAULT attribute on the ITEMS element.  The DEFAULT attribute must correspond with a NAME attribute of an ITEM.

Component View
 
This descriptor will produce the following CLOSED_LIST.

CLOSED_LIST Diplayed in Component View

Properties
 
The XML descriptor is supported by the following message.properties entries.  The NAME attribute of the ITEM maps to a property.  These properties format the item names using a mixed-case

LIST_OF_RULE_TYPES.NAME=Rule Types
LIST_OF_RULE_TYPES.ITEM.NONE_NM=None
LIST_OF_RULE_TYPES.ITEM.REQUIRED_NM=Required
LIST_OF_RULE_TYPES.ITEM.MAXLEN_NM=Max Length
LIST_OF_RULE_TYPES.ITEM.DATE_NM=Date Format

Code
 
The VALUE set by the user is available using the ElementParameterParser.getValue() call.

<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();

String ruleType = ElementParameterParser.getValue(node, "__LIST_OF_RULE_TYPES__");
%>

System.out.println("selected ruleType=<%= ruleType %>");


A CLOSED_LIST is used to prompt the user to select from a list of values.  The list is formed within a PARAMETER using list of ITEMS.  A default is specified by including an ITEM NAME in the ITEMS definition.

1 comment:

  1. Thank you for the good blog post Bekwam!

    Talend Community Manager.

    ReplyDelete