home |contents |previous |next |seek  

 

 

 

 

 

     

 

2.3.1     Notifying Listeners

Being a JavaBeans component means that a RowSet object can notify other components when certain things happen to it. For example, if data in a RowSet object changes, the RowSet object can notify interested parties of that change.

A listener for a RowSet object is a component that implements the following

methods from the RowSetListener interface:

cursorMoved—defines what the listener will do, if anything, when the cursor

in the RowSet object moves

rowChanged—defines what the listener will do, if anything, when one or

more column values in a row have changed, a row has been inserted, or a

row has been deleted

rowSetChanged—defines what the listener will do, if anything, when the

RowSet object has been populated with new data.

An example of a component that might want to be a listener is a BarGraph object

that graphs the data in a RowSet object. As the data changes, the BarGraph object

can update itself to reflect the new data.

Add a listener :

crs.addRowSetListener(bar);

Remove a listener:

                            crs.removeRowSetListener(bar);

 

 

Copyright©2008. All rights reserved.