i basically followed an example. my backing bean builds the model by creating treenodes from my menunodes. i guess this is pretty straight forwar and no issue here:
Code:
import com.icesoft.faces.component.tree.IceUserObject;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;
import org.jboss.seam.annotations.*;
import org.jboss.seam.log.*;
import java.util.*;
/**
* <p/>
* A basic backing bean for a ice:tree component. The only instance variable
* needed is a DefaultTreeModel Object which is bound to the icefaces tree
* component in the jspx code.</p>
* <p/>
* The tree created by this backing bean is used to control the selected
* panel in a ice:panelStack.
* </p>
*/
@Name("tree")
public class TreeBean {
@Logger
Log log;
// tree default model, used as a value for the tree component
private DefaultTreeModel model;
// default node icons for xp thme
private static final String XP_BRANCH_CONTRACTED_ICON = "./xmlhttp/css/xp/css-images/tree_folder_open.gif";
private static final String XP_BRANCH_EXPANDED_ICON = "./xmlhttp/css/xp/css-images/tree_folder_close.gif";
private static final String XP_BRANCH_LEAF_ICON = "./xmlhttp/css/xp/css-images/tree_document.gif";
public TreeBean() {
MenuNode node = MenuBean.MENU;
// create root node with its children expanded
DefaultMutableTreeNode rootTreeNode = new DefaultMutableTreeNode();
IceUserObject rootObject = new IceUserObject(rootTreeNode);
rootObject.setText(node.getLabel());
rootObject.setExpanded(true);
rootObject.setBranchContractedIcon(XP_BRANCH_CONTRACTED_ICON);
rootObject.setBranchExpandedIcon(XP_BRANCH_EXPANDED_ICON);
rootObject.setLeafIcon(XP_BRANCH_LEAF_ICON);
rootTreeNode.setUserObject(rootObject);
// model is accessed by by the ice:tree component
model = new DefaultTreeModel(rootTreeNode);
fillSubbranch(node, rootTreeNode);
}
private void fillSubbranch(MenuNode node, DefaultMutableTreeNode rootTreeNode) {
List<MenuNode> nodes = node.getMenuEntries();
if (nodes != null) {
for (MenuNode menuNode : nodes) {
DefaultMutableTreeNode branchNode = new DefaultMutableTreeNode();
IceUserObject branchObject = new IceUserObject(branchNode);
branchObject.setText(menuNode.getLabel());
branchObject.setBranchContractedIcon(XP_BRANCH_CONTRACTED_ICON);
branchObject.setBranchExpandedIcon(XP_BRANCH_EXPANDED_ICON);
branchObject.setLeafIcon(XP_BRANCH_LEAF_ICON);
branchNode.setUserObject(branchObject);
rootTreeNode.add(branchNode);
if(menuNode.getMenuEntries() != null && !menuNode.getMenuEntries().isEmpty()){
fillSubbranch(menuNode, branchNode);
}
}
}
}
/**
* Gets the tree's default model.
*
* @return tree model.
*/
public DefaultTreeModel getModel() {
return model;
}
}
my htmlx looks like this:
Code:
...
<f:subview id="west">
<ui:insert name="west">
<ice:form>
<ice:tree id="tree"
value="#{tree.model}"
var="item"
hideRootNode="false"
hideNavigation="false"
imageDir="./xmlhttp/css/xp/css-images/">
<ice:treeNode>
<f:facet name="icon">
<ice:panelGroup style="display: inline">
<h:graphicImage value="#{item.userObject.icon}"/>
</ice:panelGroup>
</f:facet>
<f:facet name="content">
<ice:panelGroup style="display: inline">
<ice:commandLink
value="#{item.userObject.text}"/>
</ice:panelGroup>
</f:facet>
</ice:treeNode>
</ice:tree>
</ice:form>
</ui:insert>
</f:subview>
...
One very important thing for me was to enable the jboss-webloader:
Try using the JBossWebLoader setting. Check out this posting.
That was it. It's running like a charm.