I think you may be misunderstanding the use of PAGE scope:
The page context. Begins during the invoke application phase prior to rendering a page, and lasts until the end of any invoke application phase of a faces request originating from that page. Non-faces requests do not propagate the page scope.
If you go to request any other page (
redirect to an excel template page), the previous page context is lost.
It sounds like what you want is a long-running conversation context, instead.
Actually I do understand the problem here, but what I want is to download the generated excel file without losing the page context. Is it possible?
I tried a different approach using long-running conversation between two browser windows.
I was starting a conversation as soon as I could see that the generated file was ok.
On the oncomplete of the action button I opened a browser window that was pointing to the excel template passing the actual conversation id.
In the .page.xml of this excel template I was ending the conversation.
But after ending this conversation when I tried to do something in the main page the browser was refreshing and starting a new conversation, losing the page context too.
Tried to use nested conversation too. But got no success. I'm not sure I did it right in this case, but the same thing happened.