I'm in the following situation:
- JSF (MyFaces 2.1.7 and RichFaces 3.3.3)
- A session Scoped Bean TEST_PAGE
- Users who will use BACK button to no end
- State Saving on Server
Scenario:
- User click a link to navigate to page with Session Scoped bean (TEST_PAGE)
- User clicks another link
- User presses back button of brwoser which puts them back in TEST_PAGE
- User Tries to Search in this page
On search the backing bean throws exceptions since there are many null
values. Reason being is that when they pressed "Search", the page is in RESTORE_VIEW
phase.
I tried disabling caching on the page, to force user to refresh the page on back button, but backlash caused by many users complaining "why can't I use back button, I could do it before!" and resulted in Help Desk Tickets since they think the application is crashing on "Confirm Form Resubmission" page chrome/IE/Firefox show, hence managers want me to look for alternatives.
My questions:
It is possible to detect the current Phase_ID of RESTORE_VIEW and not do any processing in this phase to avoid the exceptions, but that alone and just retuning gives user a partial page view. Is it possible to put the page in RENDER_RESPONSE
in this scenario and do the processing then? This should refresh the page.
Question Part 2
Since the recommendation (or common/good) practive is to disable cache on dynamic pages i have done so and will have to re-educate the stubborn users.
However i have the following issue.
When pressing Back button on a page with disabled cache, the browser shows the "Confirm Form Resubmission" (chrome) where users either can press Refresh / F5
or Enter
key.
If Refresh/ F5
is the action, everything is ok where i detect RESTORE_VIEW
phase and avoid any processing in that PHASE and let the processing be done in RENDER_RESPONSE
phase. However if Enter
is pressed, The PhaseID is in RENDER_RESPONSE(6)
but values of few drop-down controls is null which causes the page to fail. So i put in checks to detect such conditions and show a FaceMessage to tell the user to Refresh the page.
Question is, Can i force the page to Refresh instead of forcing the user to do it? The Navigation case for this page is in format:
<navigation-rule>
<navigation-case>
<from-outcome>/app/ord/r1</from-outcome>
<to-view-id>/jsp/ordersHistory.jsp</to-view-id>
</navigation-case>
</navigation-rule>
I've seen code snippets online where faces-redirect=true
is used to force reload a page but i couldn't get that to work! Any suggestions?