The Java visual editor provides action binders for calling a service
on a data source when a button is clicked. For example, when the Update button
is clicked, the application should run a modifyEmployee() method on the Web
service with the changes entered into the details fields. In this lesson,
you will bind the Update button to an action binder.
To bind the Update button:
- Select the Update button in the design area,
and click the Bind tab to open the Component Action
Bindings dialog box.

- In the Source type field, select Web
Service.
- In the Data source field, select webServiceDataSource.
- From the Source service list, select modifyEmployee(directory.service.FullEmployeeRecord).
- The Name field automatically changes to modifyEmployeeAction.
Accept this default.
- In the Argument field, select selectedEmployeeRecord.
- Because the modifyEmployee() method takes a full employee record
as its argument, you must leave the Property field
blank.
- Set the Initial state of the button to Disabled.

- To define how the button changes its state, click Enablement
rules. Specify that the button is enabled only when the argument's
content is changed, and disabled in all other instances. Click OK.

This means that the Update button
is disabled until the contents of the selectedEmployeeRecord changes. In other
words, as soon as you type a new value in one of the details fields, which
are bound to the selectedEmployeeRecord, the binder enables the button. If
you select a new record or click Update, the button
will become disabled again.
- Click OK.
A new SwingDataServiceAction binder is added for the Update button.
If you select the button in the design area, the visual editor draws a line
that indicates that the button is bound to the Web service data source. A
pink, dotted arrow points from the selectedEmployeeRecord object to the line.
This arrow indicates that the selectedEmployeeRecord is the argument for the
call to the service.
Lesson checkpoint
Now, when you run the application, you can update an employee's
record.
Select an employee in the table and change the last name. As soon
as you change the last name, the Update button is enabled.
When you click Update, the modifyEmployee service is
called and the employee is updated. The new last name is reflected in the
employees table.