Problem with ice:Tree
asriel Oct 19, 2009 4:36 PMHello,
I'm trying (unsuccesfully) to display a Tree component (ice:Tree) to show a list of entities (Sperimentazione). A Sperimentazione can have child nodes (relationship one to many with the entity Fase).
I tried to follow the example given in the ICEFaces' SEAM Component Showcase, but I received this error:
Exception during request processing: Caused by javax.servlet.ServletException with message: "java.lang.Exception: javax.faces.FacesException: Problem in renderResponse: null" com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:179) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) ..... Caused by javax.faces.FacesException with message: "Problem in renderResponse: null" com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:296) com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) ..... Caused by java.lang.NullPointerException with message: "" com.icesoft.faces.component.tree.TreeRenderer.encodeNode(TreeRenderer.java:367) com.icesoft.faces.component.tree.TreeRenderer.encodeParentAndChildNodes(TreeRenderer.java:268) com.icesoft.faces.component.tree.TreeRenderer.encodeChildren(TreeRenderer.java:225) javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358) .....
This is the view:
<ice:panelGroup>
<ice:tree id="tree"
value="#{treeModel}"
var="node"
hideRootNode="false"
hideNavigation="false">
<ice:treeNode>
<f:facet name="content">
<ice:panelGroup>
<ice:outputText value="Prova"/>
</ice:panelGroup>
</f:facet>
</ice:treeNode>
</ice:tree>
</ice:panelGroup>
This is the controller:
@Name("testTreeController")
@Scope(ScopeType.PAGE)
public class TestTreeController {
@In(create = true)
private SperimentazioneList sperimentazioneList;
@Out(scope = ScopeType.PAGE)
private DefaultTreeModel treeModel;
public TestTreeController() {
super();
}
@Factory("treeModel")
public void treeModelFactory() {
DefaultMutableTreeNode rootNode = makeNode(null, true, "RADICE", new Object());
((AgnosticIceTreeNode) rootNode.getUserObject()).setExpanded(true);
for (Sperimentazione sp : sperimentazioneList.getResultList()) {
DefaultMutableTreeNode spNode = makeNode(rootNode, true,
"Sperimentazione " + sp.getIdAmministrativo(), sp);
for (Fase fs : sp.getFases()) {
DefaultMutableTreeNode fsNode = makeNode(spNode, false,
fs.getClsFase().getTipo() + "." + fs.getIstanza() + " (" + fs.getStato() + ")", fs);
}
}
treeModel = new DefaultTreeModel(rootNode);
}
private DefaultMutableTreeNode makeNode(DefaultMutableTreeNode parent, boolean internalNode,
String title, Object object) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode();
AgnosticIceTreeNode userObject = new AgnosticIceTreeNode(node);
node.setUserObject(userObject);
userObject.setPayload(object);
// non-employee node or branch
if (internalNode) {
userObject.setText(title);
userObject.setLeaf(false);
userObject.setExpanded(true);
node.setAllowsChildren(true);
}
// employee node
else {
userObject.setLeaf(true);
node.setAllowsChildren(false);
}
// finally add the node to the parent.
if (parent != null) {
parent.add(node);
}
return node;
}
}
AgnosticIceTreeNode is a wrapper for IceUserObject that accepts as its payload any java object.
If someone has an idea of why this does not work, please step forward! :)
Thanks.