public void setOwner ( ListenerOwner owner ) { super . setOwner ( owner ) ; if ( owner != null ) { MoveOnValidHandler moveBehavior = null ; m_record . setOpenMode ( m_record . getOpenMode ( ) | DBConstants . OPEN_CACHE_RECORDS ) ; // Cache recently used records. m_bMoveBehavior = false ; // This flag is set automatically if the Valid record listener has to be used ReadSecondaryHandler listenerDup = ( ReadSecondaryHandler ) this . getOwner ( ) . getListener ( this . getClass ( ) ) ; while ( ( listenerDup != this ) && ( listenerDup != null ) ) { if ( listenerDup . getRecord ( ) == this . getRecord ( ) ) if ( listenerDup . getActualKeyArea ( ) == this . getActualKeyArea ( ) ) { listenerDup . setRecord ( null ) ; this . getOwner ( ) . removeListener ( listenerDup , true ) ; // Make sure there is only one break ; } listenerDup = ( ReadSecondaryHandler ) listenerDup . getListener ( this . getClass ( ) ) ; } this . fieldChanged ( DBConstants . DISPLAY , DBConstants . READ_MOVE ) ; // SCREEN_MOVE says this is coming from here if ( owner instanceof ReferenceField ) { m_keyField = m_record . getKeyArea ( keyAreaName ) . getField ( DBConstants . MAIN_KEY_FIELD ) ; // Handle field (note - null keyAreaName -> counter field) moveBehavior = new MoveOnValidHandler ( ( ( BaseField ) owner ) , m_keyField , null , true , true ) ; // Its okay to sync the key with references m_keyField = null ; } else { MainReadOnlyHandler listener = new MainReadOnlyHandler ( keyAreaName ) ; m_keyField = m_record . getKeyArea ( keyAreaName ) . getField ( DBConstants . MAIN_KEY_FIELD ) ; m_keyField . addListener ( listener ) ; // Make sure this field has the BaseListener to read it's file // Make sure you move the key field to this field!! moveBehavior = new MoveOnValidHandler ( ( ( BaseField ) owner ) , m_keyField , null , false , true ) ; } m_record . addListener ( moveBehavior ) ; } else { if ( m_bCloseOnFree ) if ( this . getDependentListener ( ) != null ) // If close and file is still open { this . setDependentListener ( null ) ; // If case you want to delete me! if ( m_record != null ) m_record . free ( ) ; // File is still open, and my listener is still there, close it! } m_record = null ; m_keyField = null ; } }
Set the field that owns this listener . This method adds the methods that allow a record to read itself if the main key field is changed .