In the first scenario, you have hard-coded the list in a tJava
component. However, the items of the list might come from a data source. For example, the
items can be stored in a database table and their number can be unknown.
This Job uses the
following components:
a tMysqlInput component to query the people information
from the employee table,
a tJavaFlex component to prepare the dynamic drop-down
list and store the value selected by the user at runtime, in the context
variable,
a second tMysqlInput component to generate the
information processed by tJavaFlex,
a tLogRow component to print the result in the
console.
Procedure
Drop a tMysqlInput component and a
tJavaFlex component from the Palette onto the design
workspace. Connect the two components using a Row > Main
link.
Drop a second tMysqlInput component and a
tLogRow component from the Palette onto the design
workspace. Connect the two components using a Row > Main
link. Connect the first subJob to the second using a Trigger > On
Subjob Ok connection.
Click the Context view and define a context variable named
named of String type:
Double-click the first tMysql and configure it as in the above example:
add the following query in the query
box:
"select name from employee"
Edit Schema and set this schema.
Click on tJavaFlex to open its Basic
settings view and add the following code.
String [] nameList=new String[list.size()];
nameList=list.toArray(nameList);
JFrame frame = new JFrame("Input Dialog Example");
String returnValue = (String) JOptionPane.showInputDialog(frame,
"Select the name you want to query?","Employee Information",JOptionPane.QUESTION_MESSAGE,null,nameList,nameList[0]);
context.name=returnValue;
In the Advanced Settings panel of
tJava, import the full path of the class used in this
Job.
Configure the second tMysqlInput component to query the people information from
the employee table, and use the tLogRow to print the result in the console, as
in the above scenario.
Execute the Job. All the names in the table will be the items of the list as
shown below:
For example, select Nicolas from the list. The
information related to Nicolas is queried from the table and printed in the
console.
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!