Is there a way i can handle browser refreshes event inside my JSF 2.0 application so that the user be navigated to the welcome page when a browser refreshes the page? and that leads me to another question of how to make page navigation inside managed bean?
Cheers,
Use a single view wherein you conditionally render includes.
<h:panelGroup id="body">
<ui:include src="#{bean.page}.xhtml" />
</h:panelGroup>
Make the bean view scoped and use commandlinks with <f:ajax>
to change the included page.
<h:form>
<h:commandLink value="Page 1" action="#{bean.setPage('page1')}">
<f:ajax execute="@this" render=":body" />
</h:commandLink>
<h:commandLink value="Page 2" action="#{bean.setPage('page2')}">
<f:ajax execute="@this" render=":body" />
</h:commandLink>
</h:form>
If you set the welcome page as default include page during bean's (post)construction, then a fresh new GET request will always show the welcome page. The only disadvantage is that those pages are not bookmarkable anymore, but that doesn't seem to be a major concern given this particular functional requirement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With