I have this PhaseListener that checks whether the user is still logged in or not after restoring a view. If the session has expired, then I want the entire form to redirect to the /login.jsf page but instead it only redirects the iframe within.
Basically, this is my code in the afterPhase() method:
if (isWebUserLogonOk(session)) {
NavigationHandler nh = faces.getApplication.getNavigationHandler();
nh.handleNavigation(faces, null, "loggedoff");
}
Where loggedoff is a navigation case that takes you to login.jsp page.
The redirect is done as expected but in this particular case I want it to be done for the entire form and not the iframe (JSF rookie talking here).
If you do not want to have a page (eg the login page) shown in an iFrame, a javascript framekiller should solve this.
Add the following code into your login pages head
and try again:
<script type="text/javascript">
if(top != self) top.location.replace(location);
</script>
It easily reloads the current page as top page.
Hope it helps...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.