Dynamic Tree from external xhtml.

UI Components for JSF
Post Reply
aprox
Posts: 4
Joined: 30 May 2016, 19:20

30 May 2016, 19:51

This is my first post here so hello everyone :)

I have problem with Tree component. I want to use it from external xhtml which is included by includeFacelet method from FaceletContext.

So I have xhtml with commandButton which executes action:

Code: Select all

FaceletContext faceletContext = (FaceletContext) FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
faceletContext.includeFacelet(component, "example.xhtml");
In example.xhtml I have:

Code: Select all

<ui:composition xmlns="http://www.w3c.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">

    <h:form>
        <p:tree id="treeTest" value="#{exampleBean.treeRoot}" var="node" dynamic="true">
            <p:treeNode>
                <h:outputText value="#{node}"/>
            </p:treeNode>
        </p:tree>
    </h:form>
</ui:composition>
After click on commandButton treeTest rendered correctly, but when I try to expand some node I have this exception:

Code: Select all

ERROR j.e.r.webcontainer.jsf.context - javax.faces.FacesException: Unsupported tree node type:default
	at org.primefaces.component.tree.Tree.getUITreeNodeByType(Tree.java:256)
	at org.primefaces.component.tree.TreeRenderer.encodeTreeNode(TreeRenderer.java:492)
	at org.primefaces.component.tree.TreeRenderer.encodeTreeNodeChildren(TreeRenderer.java:599)
	at org.primefaces.component.tree.TreeRenderer.encodeEnd(TreeRenderer.java:180)
	at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
	at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:582)
	at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
	at org.primefaces.component.api.UITree.visitTree(UITree.java:738)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIForm.visitTree(UIForm.java:371)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
	at com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
	at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:322)
	at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57)
	at javax.faces.component.UIViewRoot.encodeChildren(UIViewRoot.java:1004)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:432)
	at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
The same error appear when I define ajax actions on expand node or when I add test commandButton which created new exampleBean.treeRoot and refreshed treeTest.

When Tree component is defined on base xhtml everything is ok.
I use external xhtml with others primefaces components which I add dynamically by includefacelet method and it works fine.

Is this some kind of bug or I do something wrong?

Thanks for help.
Primefaces 6.0, JSF 2.2.13

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

31 May 2016, 22:45

does it work if you create a small example that instead of a tree uses a simple primefaces commandbutton? or a plain jsf button with ajax? Is the correct js included?

aprox
Posts: 4
Joined: 30 May 2016, 19:20

01 Jun 2016, 07:47

kukeltje wrote:does it work if you create a small example that instead of a tree uses a simple primefaces commandbutton? or a plain jsf button with ajax? Is the correct js included?
Yes, it works with primefaces commandButton with action and e.g. tabView with ajax event.

When I remove dynamic property on tree and load all nodes at start it works but it's not good solution :)

I tested it in Primefaces 6.0 RC4 and still the same error.
Primefaces 6.0, JSF 2.2.13

aprox
Posts: 4
Joined: 30 May 2016, 19:20

07 Jun 2016, 07:50

I created an issue on github with fully example:
https://github.com/primefaces/primefaces/issues/1496
Primefaces 6.0, JSF 2.2.13

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests