我遇到了icefaces树的问题,我没有得到支持bean的当前节点值。所以,我决定使用nodevalue(text)获取值。任何人都可以告诉我,如何使用nodevalue(string)获取DefaultMutableTreeNode,以便我可以将其设置为currentnode。
答案 0 :(得分:0)
我实际上正在猜测你的问题。我不太确定你的意思,但我会去拍。它可能对你有帮助。
这来自我的一个旧项目。我现在也建议使用Primefaces。更容易使用,更容易主题,更快(根据我的经验)和更多组件。
<ice:tree id="tree"
value="#{TreeController.model}"
var="node"
hideRootNode="false"
hideNavigation="false"
imageDir="./xmlhttp/css/rime/css-images/">
<ice:treeNode>
<f:facet name="icon">
<ice:panelGroup style="display: inline">
<h:graphicImage value="#{node.userObject.icon}"/>
</ice:panelGroup>
</f:facet>
<f:facet name="content">
<ice:panelGroup style="display: inline">
<ice:commandLink disabled="#{!PkgLineTableController.tableRendered}"
actionListener="#{TreeController.locationNodeSelected}">
<f:param name="treeId"
value="#{node.userObject.tree.treeId}"/>
<f:param name="name" value="#{node.userObject.text}"/>
<ice:outputText id="TreeNode"
value="#{node.userObject.text}"/>
</ice:commandLink>
</ice:panelGroup>
</f:facet>
</ice:treeNode>
</ice:tree>
支持bean:
private DefaultMutableTreeNode findTreeNode(String nodeId) {
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) getModel().getRoot();
DefaultMutableTreeNode node;
TreeObject tmp;
Enumeration nodes = rootNode.depthFirstEnumeration();
while (nodes.hasMoreElements()) {
node = (DefaultMutableTreeNode) nodes.nextElement();
tmp = (TreeObject) node.getUserObject();
if (nodeId.equals(String.valueOf(tmp.getTree().getTreeId()))) {
return node;
}
}
return null;
}
/**
* Method fired when a node is selected on the tree. This calls a few methods from the packageLineBean to build the
* package line list.
*/
public void locationNodeSelected(ActionEvent event) {
PkgLineTableController pkgLineTableController = PkgLineTableController.getCurrentInstance();
String tree_id = FacesUtils.getRequestParameter("treeId");
selectedTreeNodeName = FacesUtils.getRequestParameter("name");
DefaultMutableTreeNode node = findTreeNode(tree_id);
selectedTreeObject = ((TreeObject) node.getUserObject());
pkgLineTableController.getPkgLineTreeList().clear();
pkgLineTableController.digPackageLines(Integer.parseInt(tree_id));
pkgLineTableController.setEffect(new Appear());
WrapSpecTableController.getCurrentInstance().getWrapSpecList().clear();
}