JSF Phase Listener重定向表单不是iframe [英] JSF Phase Listener redirect form not iframe

查看:127
本文介绍了JSF Phase Listener重定向表单不是iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个PhaseListener,用于在恢复视图后检查用户是否仍然登录。如果会话已过期,那么我希望整个表单重定向到/login.jsf页面,而只是重定向iframe。

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.

基本上,这是我的afterPhase()方法中的代码:

Basically, this is my code in the afterPhase() method:

if (isWebUserLogonOk(session)) {
  NavigationHandler nh = faces.getApplication.getNavigationHandler();
  nh.handleNavigation(faces, null, "loggedoff");
}

其中,logoff是一个导航案例,可以将您带到login.jsp页面。

Where loggedoff is a navigation case that takes you to login.jsp page.

重定向按预期完成,但在这种特殊情况下,我希望它可以用于整个表单,而不是iframe(JSF新手在这里说话)。

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).

推荐答案

如果您不想拥有iFrame中显示的页面(例如登录页面),则 javascript framekiller 应该解决这个问题。

If you do not want to have a page (e.g. the login page) shown in an iFrame, a javascript framekiller should solve this.

将以下代码添加到您的登录页面 head ,然后重试:

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...

这篇关于JSF Phase Listener重定向表单不是iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆