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 ...

Monday, March 28, 2011

Component Field CHECK in Talend Open Studio

To retrieve a boolean value (true, false) from the user for configuring a custom component in Talend Open Studio, define a PARAMETER with a FIELD attribute of CHECK.

The CHECK parameter displays a checkbox in the Component View.  The checkbox retrieves a boolean value (true/false, yes/no, etc.) from the user.  The boolean value can be used to provide a condition for processing or to toggle part of the Component View display.

Component View
This screenshot shows a CHECK parameter configuring a component.

A Component with a CHECK Parameter
XML Descriptor
A parameter "SHOW_P3" is defined as a FIELD "CHECK".
XML Descriptor with a CHECK Parameter
The SHOW_P3 parameter is linked to another parameter (a textbox).  If SHOW_P3 evaluates to true -- if the checkbox is checked -- then the textbox is shown.  Otherwise, the textbox is hidden.

The following is a list of attributes that can be set on a CHECK parameter.
  • FIELD.  For a checkbox, this is "CHECK".
  • NAME.  A unique name for the checkbox.  Used in the begin, main, and end Javajet files.
  • NUM_ROW.  Row position of the components.  If used in more than one component, more than one UI control will appear in the same row.
  • SHOW_IF.  An expression that toggles the display of the checkbox.
Using the SHOW_P3 parameter in Java JET code, you can convert the String usually returned by the ElementParameterParser into a Boolean.  This allows SHOW_P3 to be concisely used in an if statement.  (Autobox, a Java 5 feature, will further convert this to a primitive boolean.) 

The following listing retrieves a variable "showp3_s" from the CHECK as a String, converts showp3_s to a Boolean showp3, and uses the variable in an if statement.

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

  String showp3_s = ElementParameterParser.getValue(node, "__SHOW_P3__");
  Boolean showp3 = new Boolean(showp3_s);  

  String param3 = ElementParameterParser.getValue(node, "__PARAM3__");

System.out.println("p1=<%= param1 %>");
System.out.println("p2=<%= param2 %>");

if( <%= showp3_s %> ) {
  System.out.println("p3=<%= param3 %>");

For boolean values, use a CHECK PARAMETER.  The boolean value can drive a UI element like a textbox in the Component View.

No comments:

Post a Comment