I am trying to redirect to xhtml pages using the p:treenode and having externalContext.redirect on onNodeSelect method, it works perfect in firefox and chrome but not on IE (versions 9, 11 and edge are the ones I tried).
On IE the page continuously redirects to the same page once I click on a tree node.
My application opens in window.open, when I use the direct url for my application in IE, I do not see this redirect looping issue, it only happens when I open my application in window.open that too only in IE.
Here is the window.open logic
<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>
The launch 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>
my xhtml which prints my navigation
<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>
backing bean NavigationTree, the NavigationBean is just a pojo which has string attributes name and link. Added a debug statement inside onNodeSelect method, the control goes into the method only once
@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());
}
}
And NavigationService is where i build the navigation
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);
...
}
}
This is from the logs where I print redirect along with the deltaspike windowContext.getCurrentWindowId(), I do not see any javascript errors in developer tools
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
Using Mojarra 2.2.12-jbossorg-2 with PrimeFaces 6.1, deltaspike 1.7.2, CDI 1.2, Windows 7 & 10, Internet Explorer 9, 11 and edge.
Any help is greatly appreciated.
The issues are fixed by deltaspike in release 1.8.1, if you want to look at the defects multiple redirects and ie window.name