This content has been marked as final.
Show 3 replies
-
1. Re: Drag and Drop component
nbelaevski Dec 26, 2008 7:30 AM (in response to yogesh_dabhi)Hi Yogesh,
Yes, it's possible. Richfaces drag'n'drop doesn't mean moving components in tree; it just calls drag/drop listeners so that you can implement chosen scenario yourself - move/clone/create new/etc. -
2. Re: Drag and Drop component
yogesh_dabhi Dec 26, 2008 7:57 AM (in response to yogesh_dabhi)have you any example for that so i can implement it
Thanks abd Regards
Yogesh N Dabhi -
3. Re: Drag and Drop component
nbelaevski Dec 28, 2008 10:39 AM (in response to yogesh_dabhi)Session-scoped bean:
package org.richfaces; import java.util.ArrayList; import java.util.List; import org.richfaces.event.DropEvent; public class DndDemoBean { public static class Item { private String name; public Item(String name) { super(); this.name = name; } public String getName() { return name; } } private List<Item> items = new ArrayList<Item>(); private Item createItem(String name) { return new Item(name); } public void processDrop(DropEvent dropEvent) { Item newItem = createItem((String) dropEvent.getDragValue()); items.add(newItem); } public List<Item> getItems() { return items; } public String[] getMakers() { return new String[]{"Sony", "Dell", "HP"}; } }
Page code:<?xml version="1.0" encoding="ISO-8859-1" ?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/> <jsp:output omit-xml-declaration="no" doctype-root-element="html" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <f:view> <h:form> <h:panelGrid columns="2"> <rich:dataTable value="#{dndDemoBean.makers}" var="maker"> <h:column> <f:facet name="header"> <f:verbatim> Makers choice </f:verbatim> </f:facet> <h:outputText value="#{maker}" /> <rich:dragSupport dragValue="#{maker}" dragType="maker" /> </h:column> </rich:dataTable> <a4j:outputPanel layout="block" id="makersList"> <rich:dataTable value="#{dndDemoBean.items}" var="item"> <h:column> <f:facet name="header"> <f:verbatim> Makers list </f:verbatim> </f:facet> <h:outputText value="#{item.name}" /> </h:column> </rich:dataTable> <rich:dropSupport dropListener="#{dndDemoBean.processDrop}" acceptedTypes="maker" reRender="makersList"/> </a4j:outputPanel> </h:panelGrid> </h:form> </f:view> </jsp:root>