public void addMainKeyBehavior ( ) { // Add the read keyed listener to all unique keys with one field Record record = this . getMainRecord ( ) ; if ( record == null ) return ; int keyCount = record . getKeyAreaCount ( ) ; for ( int keyNumber = DBConstants . MAIN_KEY_AREA ; keyNumber < keyCount + DBConstants . MAIN_KEY_AREA ; keyNumber ++ ) { KeyArea keyAreaInfo = record . getKeyArea ( keyNumber ) ; if ( ( ( keyAreaInfo . getUniqueKeyCode ( ) == DBConstants . UNIQUE ) || ( keyAreaInfo . getUniqueKeyCode ( ) == DBConstants . SECONDARY_KEY ) ) & ( keyAreaInfo . getKeyFields ( ) == 1 ) ) { BaseField mainField = keyAreaInfo . getField ( DBConstants . MAIN_KEY_FIELD ) ; MainFieldHandler readKeyed = new MainFieldHandler ( record . getKeyArea ( keyNumber ) . getKeyName ( ) ) ; mainField . addListener ( readKeyed ) ; } } }
Add the read - main - key listener .