@ Override public void keep ( String key ) { _checkFlashScopeDisabled ( ) ; FacesContext facesContext = FacesContext . getCurrentInstance ( ) ; Map < String , Object > requestMap = facesContext . getExternalContext ( ) . getRequestMap ( ) ; Object value = requestMap . get ( key ) ; // if the key does not exist in the requestMap, // try to get it from the execute FlashMap if ( value == null ) { Map < String , Object > executeMap = _getExecuteFlashMap ( facesContext ) ; // Null-check, because in the GET request of a POST-REDIRECT-GET // pattern there is no execute map if ( executeMap != null ) { value = executeMap . get ( key ) ; // Store it on request map so we can get it later. For example, // this is used by org.apache.myfaces.el.FlashELResolver to return // the value that has been promoted. requestMap . put ( key , value ) ; } } // put it in the render FlashMap _getRenderFlashMap ( facesContext ) . put ( key , value ) ; facesContext . getApplication ( ) . publishEvent ( facesContext , PostKeepFlashValueEvent . class , key ) ; }
Take a value from the requestMap or if it does not exist from the execute FlashMap and put it on the render FlashMap so it is visible on the next request .