0

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.

Pavel S.
  • 1,202
  • 1
  • 13
  • 29
  • Did you try 1.5 snapshot? [This issue was acknowledged and fixed in 1.5](https://code.google.com/p/omnifaces/source/detail?r=18fd573305d32cf27af63eed0d836ca688721a28). – BalusC May 28 '13 at 12:26
  • @BalusC, I've just tried omnifaces-1.5-SNAPSHOT-20130422.jar, but it did not help. No surprise, the code for RestorableViewHandler#restoreView() is identical with version 1.4. – Pavel S. May 28 '13 at 12:59
  • 1
    Sorry, it was fixed in April 30 and the publicly downloadable snapshot is from April 22. The snapshot with the fix is available in Maven and in ticket itself: https://code.google.com/p/omnifaces/issues/detail?id=172 – BalusC May 28 '13 at 13:07
  • We are currently very busy with other duties which postponed the 1.5 release everytime. We are trying to release the final 1.5 this week once the changes in FacesViews have thoroughly been tested. – BalusC May 28 '13 at 13:09
  • @BalusC, I've taken omnifaces-1.5-SNAPSHOT-20130430.jar, and now I'm having another problem that appeared when I tried using OmniFaces version 1.3: declared in the view is totally ignored and the ViewExpiredException is thrown. Do you have any idea off-hand? I can see that the presence of the tag is tested in different ways in 1.4 and 1.3/1.5... – Pavel S. May 28 '13 at 13:22

0 Answers0