What is a drop-down list?
A drop-down list is a user interface control GUI element ("widget" or "control"), that displays a list of values and allows the user to select one value from the list at runtime.
Prerequisites
In order to create a drop-down list in a Job in the following examples, you should have a
MySQL database.
Before replicating the following examples, make sure you have created a MySQL table named employee. The table stores people information as shown below.
id | name | sex | department | position | |
---|---|---|---|---|---|
1 | Elisa | elisa@company.com | F | RD | manager |
2 | Nicolas | nicolas@company.com | M | RD | developer |
3 | Sabrina | sabrina@company.com | F | Community | developer |
4 | Stephane | stephane@company.com | M | Sales | manager |
5 | Jim | jim@company.com | M | Sales | pre-sales |
Creating a drop-down list
This Job shows how to use a MySQL database table to create a drop-down list in a
Talend job.
This Job uses the following components:
- a tJava component to prepare the drop-down list and store the value selected by the user at runtime in the context variable.
- a tMysqlInput component to query the people information from the employee table.
- a tLogRow component to print the result on the console.
Procedure
Creating a dynamic drop-down list
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.