Thursday, March 14, 2013

JSF Tip of the Day: PrimeFaces 3.0 Tree Drag and Drop Example

I worked on a proof of concept for a drag and drop enabled <p:tree /> for a project I was working on. At the time, PrimeFaces was just starting the path to 3.0, and I was working with a snapshot. The POC was part of a decision making process on which JSF framework, or combination of frameworks to use.

This drag and drop example was part of the the work Optimus Prime and his team created as a potential functionality for the <p:tree /> component. In the final release, this functionality was removed. I still have high hopes that in PrimeFaces 3.5.+ that it will be added back into the product. It was a cool idea and one that we had hoped to take advantage of in our products.

If you need this functionality currently, and don't mind using a 3.0-SNAPSHOT release, you can have a drag and drop <p:tree />. I published this since it was a good example, and I thought someone might need this specific functionality. Otherwise it is code lost in time.

The Mercurial project can be pulled from BitBucket and was developed using NetBeans and Apache Maven.

The code can be found here: primefaces-tree-dragdrop-demo

Example





8 comments :

Bubbly said...

Hi,

tried this example.Getting the below error. Please help :(

javax.el.ELException: /pages/index.xhtml: The class 'com.bluelotussoftware.example.jsf.TreeBean' does not have the property 'onNodeSelect'.
at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
at java.lang.Thread.run(Unknown Source)


Thanks,
Poo

John Yeary said...

I have a suspicion that you are not using the primefaces-3.0-SNAPSHOT.

What JDK version and Tomcat version?

Bubbly said...

jdk 1.6 and jboss7.1.0

Bubbly said...

i am using primefaces 3.5 and JDK 1.6 and jboss 7.1.0. Need help. Also need to create a tree which takes the dta from the db and add delete and edit the nodes. Please help

John Yeary said...

This specific example was a proof of concept that does not work with anything above Primefaces 3.0 as noted in my post.

We needed the same thing so we used Richfaces

Bubbly said...

Hi John,
Thanks for your response.

http://www.ethemsulan.com/2011/03/dynamic-treeview-recursively-jsf-primefacescreate-dynamic-category-java.html

I am trying to create the above example. Any suggestions from you would be of great help. I have also referred to your other example. I am currently able to create the tree. I want to add and delete nodes and display the tree dynamically. This code works on netbeans but not on eclipse.

Thanks,
Poo

John Yeary said...

The project will work on Eclipse if you are using Maven. The project is an Apache Maven project so it will work from the command line too.

As far as I can tell, you need to update the TreeModel and add additional nodes. You would need to re-render the tree, or the container that contains the tree.

Bubbly said...

Thanks. I am working on it. Do let me know if you have a sample.

Thanks,
Poo

Popular Posts