问题
I have a simple example of p:tree.
<p:tree id="tree" styleClass="treeskin" value="#{TreeViewController.root}" var="node" dynamic="true" animate="true"
selectionMode="single" selection="#{TreeViewController.selectedNode}" highlight="true">
<p:ajax event="select" listener="#{TreeViewController.onNodeSelect}" update=":treeform:outputComponent"/>
<p:ajax event="expand" listener="#{TreeViewController.onNodeExpand}" />
<p:ajax event="collapse" listener="#{TreeViewController.onNodeCollapse}" />
<p:treeNode styleClass="treeskin">
<h:outputText value="#{node}"/>
</p:treeNode>
</p:tree>
I'm interested is it possible somehow when I click on a node to open a new page. I found that using onNodeClick I can open a new page using JavaScript. But if it's possible I want to send hidden value which I will use as a key later.
What are the possible solutions?
回答1:
You could try embedding an <h:link/> in the <p:treeNode/>. Use the following construct
<h:link value="#{node}" outcome="destination?includeViewParams=true">
<f:param name="theParam" value="#{node.property}"/>
</h:link>
The includeViewParams=true bit is going to ensure the parameter you're trying to pass makes it across the request to the next page
来源:https://stackoverflow.com/questions/14802979/how-to-open-new-page-on-node-click