JSF ExternalContext.redirect IE 上的无限循环 window.open

JSF ExternalContext.redirect infinite loop on IE window.open

我正在尝试使用 p:treenode 并在 onNodeSelect 方法上使用 externalContext.redirect 重定向到 xhtml 页面,它在 firefox 和 chrome 中完美运行,但在 IE 上却不行(版本 9、11 和 edge 是我试过的)。

在 IE 上,单击树节点后,页面会不断重定向到同一页面。

我的应用程序在 window.open 中打开,当我在 IE 中为我的应用程序使用直接 url 时,我没有看到这个重定向循环问题,只有当我在 url 中打开我的应用程序时才会发生=42=] 那也只在 IE 中。

这是window.open逻辑

<div class="floatLeft" style="padding: 0 5px; width: 75px;">
    <div class="autoCenter center">
        <a href="javascript:void(0)" onClick="launch('http://pc055265.my.search.app:8080/UpgradeParis/faces/login/ssologin.xhtml?app=IHW', 'PARIS-IHW')">
          <img id="j_idt18:2:j_idt20" src="/cta-landing/javax.faces.resource/paris_IHW_50x46.png.jsf?ln=images" alt="PARISIHW" title="PARIS - IHW" />
        </a> 
        PARIS-IHW
    </div>
 </div>

发射javascript

<script type="text/javascript">
    var wnd
    function launch(url, app){
        if(!wnd || wnd.closed){
            wnd = window.open(url, app, 'height=700,width=1350,toolbar=no,location=no,menubar=no,status=no,titlebar=no,resizable=yes,scrollbars=yes');
        }
        wnd.focus();
        return false;
    }
</script>

我的 xhtml 打印我的导航

<p:tree id="navTree" name="navTree" value="#{navTree.root}" var="node" selectionMode="single" 
        selection="#{navTree.selectedNode}" >
        <p:treeNode expandedIcon="fa fa-folder-open" collapsedIcon="fa fa-folder" styleClass="navTree">
            <h:outputText value="#{node.name}" title="#{node.name}"/>
        </p:treeNode>
        <p:treeNode type="document" icon="fa fa-file-text-o fileColor" styleClass="navTree">
            <h:outputText value="#{node.name}" title="#{node.name}"/>
        </p:treeNode>
        <p:ajax event="select" listener="#{navTree.onNodeSelect}" />
</p:tree>

支持 bean NavigationTree,NavigationBean 只是一个具有字符串属性名称和 link 的 pojo。在onNodeSelect方法中添加了debug语句,控件只进入方法一次

@Named("navTree")
@SessionScoped
public class NavigationTree implements Serializable {

private TreeNode root;
private TreeNode selectedNode;

@Inject
private NavigationService service;

@PostConstruct
public void init() {
    root = service.createParisTree();
}

public void setService(NavigationService service) {
    this.service = service;
}

public TreeNode getRoot() {
    return root;
}

public TreeNode getSelectedNode() {
    return selectedNode;
}

public void setSelectedNode(TreeNode selectedNode) {
    this.selectedNode = selectedNode;
}

public void onNodeSelect(NodeSelectEvent event) throws IOException{
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    StringBuffer url = new StringBuffer(ec.getRequestContextPath()+ "/");
    TreeNode currentNode = event.getTreeNode();
    NavigationBean node = (NavigationBean) currentNode.getData();

    if(node !=null){
        url.append(node.getLink());
    }else{
        url.append("faces/ui/home.xhtml");
    }

    ec.redirect(url.toString());

}
}

而 NavigationService 是我构建导航的地方

public class NavigationService implements Serializable {

public TreeNode createParisTree() {
    TreeNode root = new DefaultTreeNode(new NavigationBean("Menu", "root"), null);
    TreeNode home = new DefaultTreeNode(new NavigationBean("Home", "faces/ui/home.xhtml"), root);
    TreeNode ihw = new DefaultTreeNode(new NavigationBean("IHW", "faces/ui/home.xhtml"), home);
    TreeNode nor = new DefaultTreeNode("document",new NavigationBean("RE Search", "faces/ui/ihw/common/facility-search.xhtml"), ihw);
    ...
}
}

这是我打印重定向以及 deltaspike windowContext.getCurrentWindowId() 的日志,我在开发人员工具中没有看到任何 javascript 错误

00:35:16,932 INFO  [stdout] (default task-38) redirectd to :RE Search Page:/ui/ihw/common/facility-search.xhtml?faces-redirect=true CID:-8766
00:35:17,057 INFO  [stdout] (default task-39) redirected to :RE Search Page:/ui/ihw/common/facility-search.xhtml?faces-redirect=true CID:382
00:35:17,214 INFO  [stdout] (default task-79) redirected to :RE Search Page:/ui/ihw/common/facility-search.xhtml?faces-redirect=true CID:-5368
00:35:17,546 INFO  [stdout] (default task-94) redirected to :RE Search Page:/ui/ihw/common/facility-search.xhtml?faces-redirect=true CID:4879
00:35:17,679 INFO  [stdout] (default task-103) redirected to :RE Search Page:/ui/ihw/common/facility-search.xhtml?faces-redirect=true CID:-9278
00:35:17,873 INFO  [stdout] (default task-124) redirected to :RE Search Page:/ui/ihw/common/facility-search.xhtml?faces-redirect=true CID:9899
00:35:18,004 INFO  [stdout] (default task-111) redirected to :RE Search Page:/ui/ihw/common/facility-search.xhtml?faces-redirect=true CID:714

将 Mojarra 2.2.12-jbossorg-2 与 PrimeFaces 6.1、deltaspike 1.7.2、CDI 1.2、Windows 7 & 10、Internet Explorer 9、11 和 edge 结合使用。

非常感谢任何帮助。

deltaspike 在发行版 1.8.1, if you want to look at the defects multiple redirects and ie window.name

中修复了这些问题