@ Override public void paint ( final RenderContext renderContext ) { if ( windowId == null ) { super . paint ( renderContext ) ; } else { // Get the window component ComponentWithContext target = WebUtilities . getComponentById ( windowId , true ) ; if ( target == null ) { throw new SystemException ( "No window component for id " + windowId ) ; } UIContext uic = UIContextHolder . getCurrentPrimaryUIContext ( ) ; Environment originalEnvironment = uic . getEnvironment ( ) ; uic . setEnvironment ( new EnvironmentDelegate ( originalEnvironment , windowId , target ) ) ; UIContextHolder . pushContext ( target . getContext ( ) ) ; try { super . paint ( renderContext ) ; } finally { uic . setEnvironment ( originalEnvironment ) ; UIContextHolder . popContext ( ) ; } } }
Temporarily replaces the environment while the UI is being rendered .