0
votes

I have this error:

jan 03, 2014 6:43:56 PM com.sun.faces.context.PartialViewContextImpl processPartial INFO: java.lang.ClassCastException: javax.faces.event.ValueChangeEvent cannot be cast to javax.faces.event.AjaxBehaviorEvent java.lang.ClassCastException: javax.faces.event.ValueChangeEvent cannot be cast to javax.faces.event.AjaxBehaviorEvent

Tree in xhtml:

                <p:tree id="catTree"
                        value="#{listCatsRenderer.categoryTree}" var="ndt"
                        selectionMode="single" 
                        selection="#{listCatsRenderer.selectedNode}"
                        draggable="true"
                        droppable="true"
                        animate="true" styleClass="tree_general"
                        propagateSelectionUp="false"
                        dynamic="true"
                        >

                    <p:ajax event="dragdrop" listener="#{listCatsRenderer.onDragDrop}" update=":main:catTree"/>

                    <p:treeNode>
                        <p:inplace event="dblclick" editor="true" >
                            <h:inputText value="#{ndt.name}"/>
                        </p:inplace>
                    </p:treeNode>  
                </p:tree>

Loading from bean is here:

@Named
@SessionScoped
public class ListCatsRenderer extends ARenderer implements Serializable {
.
.
.
@Override
public TreeNode getCategoryTree() {
    if (categoryTree == null) {
        updateCategoryTree(); //DBS load
    } 
    return categoryTree;
}

After any dragdrop event it throws exception. When I turn of condition above, it works without errors. Any idea why ? Thank you.

//EDIT Code for process event, however I thing it never gets there

public void onDragDrop(TreeDragDropEvent event) {
    System.out.println("dragged: " + event.getDragNode());
    System.out.println("dropped: " + event.getDropNode() + " > " + event.getDropIndex());
}

And full stacktrace, might help:

jan 05, 2014 11:50:28 AM com.sun.faces.lifecycle.ProcessValidationsPhase execute WARNING: java.lang.ClassCastException: javax.faces.event.ValueChangeEvent cannot be cast to javax.faces.event.AjaxBehaviorEvent javax.faces.FacesException: java.lang.ClassCastException: javax.faces.event.ValueChangeEvent cannot be cast to javax.faces.event.AjaxBehaviorEvent at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:270) at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57) at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1193) at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) 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:646) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.jboss.weld.servlet.ConversationFilter.doFilter(ConversationFilter.java:66) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724) Caused by: java.lang.ClassCastException: javax.faces.event.ValueChangeEvent cannot be cast to javax.faces.event.AjaxBehaviorEvent at org.primefaces.component.tree.Tree.queueEvent(Tree.java:308) at javax.faces.component.UIComponentBase.queueEvent(UIComponentBase.java:1057) at javax.faces.component.UIComponentBase.queueEvent(UIComponentBase.java:1057) at javax.faces.component.UIComponentBase.queueEvent(UIComponentBase.java:1057) at javax.faces.component.UIInput.validate(UIInput.java:992) at javax.faces.component.UIInput.executeValidate(UIInput.java:1249) at javax.faces.component.UIInput.processValidators(UIInput.java:712) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261) at org.primefaces.component.inplace.Inplace.processValidators(Inplace.java:218) at org.primefaces.component.api.UITree.processColumnChildren(UITree.java:442) at org.primefaces.component.api.UITree.processNode(UITree.java:372) at org.primefaces.component.api.UITree.processNode(UITree.java:380) at org.primefaces.component.api.UITree.processNodes(UITree.java:365) at org.primefaces.component.api.UITree.processValidators(UITree.java:308) at org.primefaces.component.tree.Tree.processValidators(Tree.java:377) at com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:552) at com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183) at org.primefaces.component.api.UITree.visitTree(UITree.java:552) at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700) 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 com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:399) at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:263) ... 28

1

1 Answers

1
votes

Works for me with Mojarra 2.0.3 (FCS b03), PrimeFaces 4.0.

Please tell us more about the versions you use and provide the exact code for onDragDrop method of your backing bean. I guess it is related to your method that is not using the right parameter types (TreeDragDropEvent is expected, not ValueChangeEvent).

Should be something like :

public void onDragDrop(TreeDragDropEvent event) { 
  ...
}