1
votes

Tree throws exception when selecting a node, in the backinbean it sends the value of the correct node. But the exception is not where it comes from.

log:

Información: java.lang.IllegalArgumentException: Cannot convert Territorio IV of type class org.primefaces.model.DefaultTreeNode to class com.delisa.ejb.util.utls.GrupoUtil java.lang.IllegalArgumentException: Cannot convert Territorio IV of type class org.primefaces.model.DefaultTreeNode to class com.delisa.ejb.util.utls.GrupoUtil at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:424) at com.sun.el.lang.ELSupport.coerceToType(ELSupport.java:382) at com.sun.el.parser.AstValue.setValue(AstValue.java:248) at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:294) at org.jboss.weld.el.WeldValueExpression.setValue(WeldValueExpression.java:64) at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131) at org.primefaces.component.api.UITree.updateSelection(UITree.java:524) at org.primefaces.component.api.UITree.processUpdates(UITree.java:490) at org.primefaces.component.tree.Tree.processUpdates(Tree.java:425) at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:577) 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 com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403) at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:266) at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57) at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:1252) at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:78) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:654) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at com.delisa.jsf.util.NoCacheFilter.doFilter(NoCacheFilter.java:38) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:745)

Advertencia: java.lang.IllegalArgumentException: Cannot convert Territorio IV of type class org.primefaces.model.DefaultTreeNode to class com.delisa.ejb.util.utls.GrupoUtil

my xhtml page

 <p:dialog  responsive="true" dynamic="true" showEffect="fade" resizable="false" appendTo="@(body)" modal="true"  position="center top" style="margin-top: 50px"
                           id="dialogInt" header="Seleccione donde desea moverlo" widgetVar="dialogGruph" width="600" height="600"  closeOnEscape="true">
                    <h:form id="frmGrupph">
                        <div class="Container100">

                            <div class="ContainerIndent">
                                <p:tree   id="treeEstrucph" styleClass="Wid100" value="#{mBEstructura.rootParentChange}" var="nodepc" 
                                          selectionMode="single"   selection="#{mBEstructura.selectedParentchange}" >    

                                    <p:ajax event="select" update=":frmGrupph" listener="#{mBEstructura.parentChange}" />
                                                              

                                    <p:treeNode expandedIcon="ui-icon-folder-open" collapsedIcon="ui-icon-folder-collapsed">
                                        <h:outputText value="#{nodepc}"/>
                                    </p:treeNode>
                                </p:tree> 
                            </div>       
                        </div>


                        
                        <p:blockUI block="treeEstrucph" trigger="treeEstrucph" />
                    </h:form>  
                </p:dialog>      

and finally my backingbean

 public void parentChange(NodeSelectEvent event) throws Exception {
    try {
        JbGrupos ep = (JbGrupos) event.getTreeNode().getData();
       /**
        * 
        */

    } catch (Exception e) {
        JsfUtil.addErrorMessage(e, "Error: parentChange() " + e.getMessage());
    }
}
1
check the different type of object that you use in your treeYagami Light
Please add the differente objects that you use in your tree (rootParentChange , selectedParentchange ...)Yagami Light
Gracias @YagamiLight ... eso es todo ...meyquel
did you solve the problemYagami Light
@YagamiLight, yes. thanks...meyquel

1 Answers

1
votes

The problem that you face in your tree is the object type of the different elements that you use in your tree, check every element of your tree you will find something wrong (in this case you succefully did it).

Even if the tree is constructed with TreeNode type you can for example bind it to an other type

treeConstruct = new DefaultTreeNode(new client(), null);

each node that you use in your tree can be selected and used a client data

Hope that helped you.