quick.dbtable
Class DatabaseChangeListener
java.lang.Object
quick.dbtable.DatabaseChangeListener
- public class DatabaseChangeListener
- extends java.lang.Object
This is the listener class for various quicktable events.
Method Summary |
void |
afterDelete(int row)
When a user deletes a row, the database will be updated with the
changes when he leaves that row. |
void |
afterInsert(int row)
When a user inserts a row, the database will be updated with the
changes when he leaves that row. |
void |
afterUpdate(int row)
When a user modifies data in a row, the database will be updated with the
changes when he leaves that row. |
boolean |
beforeDelete(int row)
When a user deletes a row, the database will be updated with the
changes when he leaves that row. |
boolean |
beforeInsert(int row)
When a user inserts a new row, the database will be updated with the
changes when he leaves that row. |
boolean |
beforeUpdate(int row)
When a user modifies data in a row, the database will be updated with the
changes when he leaves that row. |
boolean |
onDeleteButtonClick()
When the user clicks on the "Delete Record" button available in the control panel
this method will be called. |
boolean |
onNewButtonClick()
When the user clicks on the "New Record" button available in the control panel
this method will be called. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DatabaseChangeListener
public DatabaseChangeListener()
beforeUpdate
public boolean beforeUpdate(int row)
- When a user modifies data in a row, the database will be updated with the
changes when he leaves that row. Before the update query is fired to database
this method will be called. If you want to cancel this operation, send a return
value of "false" , else return "true"
- Parameters:
row
- the row of the cell in which the cell data is changed by the user
- Returns:
- false , if you want to cancel the database update
true , if you want the database update to happen
afterUpdate
public void afterUpdate(int row)
- When a user modifies data in a row, the database will be updated with the
changes when he leaves that row. After the update query is fired to database
this method will be called.
This method will be called only if you have added an UpdateSql.
- Parameters:
row
- the row of the cell in which the cell data is changed by the user
beforeInsert
public boolean beforeInsert(int row)
- When a user inserts a new row, the database will be updated with the
changes when he leaves that row. Before the insert query is fired to database
this method will be called. If you want to cancel this operation, send a return
value of "false" , else return "true"
Note: When you attach a DatabaseChangeListener with quicktable and during beforeInsert(), if you return false
that means you don't want quickTable to do the insert, instead you will handle the database insert
yourself. But sometimes you still want quickTable to handle the db insert the next time. In this case
if you set this property DBTable.postponeDBInsert to true, then quicktable will postpone the
insert until you return true for beforeInsert() for that record.
- Parameters:
row
- the newly added row
- Returns:
- false , if you want to cancel the database insert
true , if you want the database insert to happen
- See Also:
DBTable.postponeDBInsert
afterInsert
public void afterInsert(int row)
- When a user inserts a row, the database will be updated with the
changes when he leaves that row. After the insert query is fired to database
this method will be called.
This method will be called only if you have added an InsertSql.
- Parameters:
row
- the newly added row
beforeDelete
public boolean beforeDelete(int row)
When a user deletes a row, the database will be updated with the
changes when he leaves that row. Before the delete query is fired to database
this method will be called. If you want to cancel this operation, send a return
value of "false" , else return "true"
New change in behaviour from version 2.0.5.27 : Before this version, if user returns
false for beforeDelete(), then the record will not be deleted in database, but it will
still be deleted from UI. After 2.0.5.27, if beforeDelete() returns false, record will
NOT be deleted from both database & UI
- Parameters:
row
- the deleted row
- Returns:
- false , if you want to cancel the delete
true , if you want the delete to happen
afterDelete
public void afterDelete(int row)
- When a user deletes a row, the database will be updated with the
changes when he leaves that row. After the delete query is fired to database
this method will be called.
This method will be called only if you have added an DeleteSql.
- Parameters:
row
- the deleted row
onNewButtonClick
public boolean onNewButtonClick()
- When the user clicks on the "New Record" button available in the control panel
this method will be called. This method will help you to assign default values
for the inserted records. By default, the record will be initialized with a empty
cell values for all the cells in the new record. But usually we don't want the primary
key to be entered by the user, instead we may need to auto create the primary keys. For
example, if the user tries to create a new employee, we don't want the user to assign the
the employee id, instead we have to get the next employee id from database or from
some sequence, then use the insert(java.util.Vector insertElements) in DBTable to insert
the record. If you return a "true", that means you have already inserted the record into
quicktable, so that you don't want quicktable to insert the default record
If you return false, then you haven't handled the insert and you want quicktable to
do the default insert.
Note: This method is based on just control panel button click, it doesn't have any relation to
the actual database record insertion.
- Returns:
- false , if you have handled the insert into quicktable & you don't want quicktable to do the insert
true , if you want quicktable to do the default insert
- See Also:
DBTable.insert(Vector)
onDeleteButtonClick
public boolean onDeleteButtonClick()
- When the user clicks on the "Delete Record" button available in the control panel
this method will be called. This method will help you to ask any confirmation or
any pre delete activities which need to be done.
If you return a "true", that means you want the delete to happen
If you return false, then you don't want the delete to happen.
Note: This method is based on just control panel button click, it doesn't have any relation to
the actual database record deletion. If the user selects the record and presses the "delete"
key, this method will not be called.
- Returns:
- false , if you don't want to delete the record
true , if you want to delete the record