I have a page anchors.xhtml
which contains a form and an
<h:commandButton action="#{anchorsBean.onRefresh}" value="Refresh" />
which submits to the same page using redirect:
public String onRefresh() {
refresh();
return "anchors?faces-redirect=true";
}
I want to avoid ViewExpiredException
on session timeout or caused by other reason. For that purpose I get use of OmniFaces' restorable view handler:
<f:metadata>
<o:enableRestorableView />
</f:metadata>
But surprisingly at this point, in case of expired view, my redirection behavior gets lost: POST request/response simply takes place. Some digging into details reveals me that navigation/redirection is normally triggered by UICommand
at Invoke Application phase, however the view root restored by <o:enableRestorableView />
seems to have no children at all. So there's simply no command component to call the default action listener which must handle redirection.
I am using Mojarra 2.1.19 and OmniFaces 1.4.1. I can see in the sources that RestorableViewHandler
creates the view but does not build it: can it be the reason for the empty UIViewRoot
? Evidently, there's something I am flagrantly missing and misunderstanding...
Most interesting, when I use no <o:enableRestorableView />
but simply remove ViewExpiredException
event in my custom exception handler, everything works fine: FacesContext
happens to somehow already contain a fully built UIViewRoot
(which <o:enableRestorableView />
, when included, will later replace with an empty one). So this way I'm getting the originally desired behavior, at least things look like that. But this way is definitely wrong I suppose.
Many thanks in advance for any clarification on this.