我正在尝试使用p:treenode重定向到xhtml页面并在onNodeSelect方法上使用externalContext.redirect,它在firefox和chrome中工作得很好但在IE上却不行(版本9,11和边缘是我尝试的那些)。
在IE上,一旦我点击树节点,页面就会不断重定向到同一页面。
我的应用程序在window.open中打开,当我在IE中使用我的应用程序的直接URL时,我没有看到这个重定向循环问题,它只发生在我在window.open中打开我的应用程序时,也只在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只是一个包含字符串属性名称和链接的pojo。在onNodeSelect方法中添加了一个调试语句,控件只进入一次方法
@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&amp; 10,Internet Explorer 9,11和edge。
非常感谢任何帮助。