How to add an event listener to a control on a form.
You can run this technique code from:
NOTE First make sure that database is running on your localhost SilverStream Server
For another example using listeners, see Obtaining the Control with Focus
The form frmListeners has code that adds AgiRowSetListener for the agData control. AgiRowSetListener responds to changes in data. The input fields on the form are bound to agData, so after the user changes a value in an input field, RowSet events are generated.
The three basic steps described below apply to any listener. When you use the Programming Editor menu to add the interface, SilverStream automatically generates stubs for individual events so you don't have to worry about whether you've implemented the interface completely.
To add a listener:
In the Programming Editor, select File -> Java Interfaces to add the listener interface. Use the Help system to find out the fully qualified package for the interface. In frmListeners, the interface being added is
Be sure to check Create stubs for interface methods.
In the FormActivate event, after SilverStream has instantiated the controls, add the listener to the appropriate data control.
For example, in frmListeners, this code adds the RowSetListener to the agData control. The keyword
this refers to the form:
For example, in frmListeners, there is code behind the rowDataChanged event. To see the code in action, change a field value and tab off the field.
agDialog.showMessage("Event rowDataChanged", "The data has changed for field: " + agoPropertyChangeEvent0.getPropertyName() + "\r\nOld Value was: " + agoPropertyChangeEvent0.getOldValue() + "\r\nNew Value is: " + agoPropertyChangeEvent0.getNewValue());