private Object saveBehaviorsState ( FacesContext context ) { Object state = null ; if ( null != behaviors && behaviors . size ( ) > 0 ) { boolean stateWritten = false ; Object [ ] attachedBehaviors = new Object [ behaviors . size ( ) ] ; int i = 0 ; for ( List < ClientBehavior > eventBehaviors : behaviors . values ( ) ) { // we need to take different action depending on whether // or not markInitialState() was called. If it's not called, // assume JSF 1.2 style state saving and call through to // saveAttachedState(), otherwise, call saveState() on the // behaviors directly. Object [ ] attachedEventBehaviors = new Object [ eventBehaviors . size ( ) ] ; for ( int j = 0 ; j < attachedEventBehaviors . length ; j ++ ) { attachedEventBehaviors [ j ] = ( ( initialStateMarked ( ) ) ? saveBehavior ( context , eventBehaviors . get ( j ) ) : saveAttachedState ( context , eventBehaviors . get ( j ) ) ) ; if ( ! stateWritten ) { stateWritten = ( attachedEventBehaviors [ j ] != null ) ; } } attachedBehaviors [ i ++ ] = attachedEventBehaviors ; } if ( stateWritten ) { state = new Object [ ] { behaviors . keySet ( ) . toArray ( new String [ behaviors . size ( ) ] ) , attachedBehaviors } ; } } return state ; }
Save state of the behaviors map .