@ Override public Integer generateKey ( FacesContext facesContext ) { ExternalContext externalContext = facesContext . getExternalContext ( ) ; Object sessionObj = externalContext . getSession ( true ) ; Integer sequence = null ; // synchronized to increase sequence if multiple requests // are handled at the same time for the session synchronized ( sessionObj ) { Map < String , Object > map = externalContext . getSessionMap ( ) ; sequence = ( Integer ) map . get ( RendererUtils . SEQUENCE_PARAM ) ; if ( sequence == null || sequence . intValue ( ) == Integer . MAX_VALUE ) { sequence = Integer . valueOf ( 1 ) ; } else { sequence = Integer . valueOf ( sequence . intValue ( ) + 1 ) ; } map . put ( RendererUtils . SEQUENCE_PARAM , sequence ) ; } return sequence ; }
Take the counter from session scope and increment