Bom estou tentando implementar o DataGrid - Drag and Drop no meu projeto, mas não esta funcionando quando arrasto a imagem para o field select ele nao faz nada. A seguir meu codigo:
Minha view
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="index.xhtml">
<ui:define name="conteudo">
<h:head>
<title>Cadastro Orçamento</title>
</h:head>
<h:body>
<p:panel id="panel" header="Cadastro de Orçamentos" toggleable="false" closable="true" >
<p:growl/>
<p:focus for="mensagem" />
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="Cliente:" />
<p:selectOneMenu id="cliente" value="#{orcamentoBean.orcamento.cliente}" required="true" requiredMessage="Selecione um Cliente!">
<f:selectItem itemLabel="Selecione Cliente..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{orcamentoBean.listarclientes}" var="c" itemLabel="#{c.nome}" itemValue="#{c.id}"/>
</p:selectOneMenu>
<h:outputText value="" />
<p:fieldset legend="Produtos">
<p:dataGrid id="availableCars" var="car"
value="#{orcamentoBean.produtosSmall}" columns="5">
<p:column>
<p:panel id="pnl" header="#{car.nome}" style="text-align:center">
<h:panelGrid columns="1" style="width:100%">
<p:graphicImage value="/images/12176.jpg"/>
</h:panelGrid>
</p:panel>
<p:draggable for="pnl" revert="true"
handle=".ui-panel-titlebar" stack=".ui-panel"/>
</p:column>
</p:dataGrid>
</p:fieldset>
<h:outputText value="" />
<p:fieldset id="selectedCars" legend="Selected Cars" style="margin-top:20px">
<p:outputPanel id="dropArea">
<h:outputText value="!!!Drop here!!!"
rendered="#{empty orcamentoBean.droppedProdutos}"
style="font-size:24px;" />
<p:dataTable var="car" value="#{orcamentoBean.droppedProdutos}"
rendered="#{not empty orcamentoBean.droppedProdutos}">
<p:column headerText="Nome:">
<h:outputText value="#{car.nome}" />
</p:column>
<p:column style="width:32px">
<p:commandButton update=":form:display"
oncomplete="carDialog.show()"
icon="ui-icon-search">
<f:setPropertyActionListener value="#{car}"
target="#{orcamentoBean.droppedProdutos}" />
</p:commandButton>
</p:column>
</p:dataTable>
</p:outputPanel>
</p:fieldset>
<p:droppable for="selectedCars" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="availableCars" onDrop="handleDrop">
<p:ajax listener="#{orcamentoBean.onProdutoDrop}" update="dropArea availableCars" />
</p:droppable>
<p:dialog header="Car Detail" widgetVar="carDialog" resizable="false" draggable="false"
width="200" showEffect="fade" hideEffect="fade" modal="true">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="/images/12176.jpg"/>
</f:facet>
<h:outputText value="Nome:" />
<h:outputText value="#{orcamentoBean.droppedProdutos[1]}"/>
</h:panelGrid>
</p:dialog>
</h:panelGrid>
<p:separator style="width: 90%; height: 5px" />
<p:confirmDialog message="Deseja Cancelar?" showEffect="bounce" hideEffect="explode" modal="true"
header="Cadastro Clientes" severity="info" widgetVar="confirmacao">
<p:commandButton value="Sim" oncomplete="confirmacao.hide()"
onclick="window.location.href='index.xhtml'"/>
<p:commandButton value="Não" update="panel" onclick="confirmacao.hide()" type="button"/>
</p:confirmDialog>
<p:spacer width="30" height="10" />
<p:commandButton value="Salvar" actionListener="#{orcamentoBean.salvar}" update="panel" />
<p:spacer width="50" height="10" />
<p:commandButton value="Cancelar" onclick="confirmacao.show()" />
</p:panel>
</h:body>
</ui:define>
</ui:composition>
</html>
Eu estou usando um template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Pagina Inicial do Sistema.</title>
</h:head>
<f:view>
<h:body>
<h:form id="form" enctype="multipart/form-data">
<div>
<ui:insert name="menu"></ui:insert>
</div>
<div style="position: absolute; left:15px; top:70px; width:1040px; height:300px;">
<ui:insert name="conteudo"></ui:insert>
</div>
</h:form>
</h:body>
</f:view>
</html>
Meu bean
package managedBeans;
import interfac.ICliente;
import interfac.IOrcamento;
import interfac.IProduto;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.event.DragDropEvent;
import pojo.Cliente;
import pojo.Orcamento;
import pojo.Produto;
@ManagedBean
@SessionScoped
public class OrcamentoBean {
private Orcamento orcamento;
private Cliente clientes;
List<Cliente> listarclientes;
private Map<String,String> listarsitiacao;
//carrinho
private List<Produto> produtosSmall;
private List<Produto> droppedProdutos;
@EJB
private IOrcamento orcamentoDao;
@EJB
private IProduto produtoDao;
@EJB
private ICliente clienteDao;
public OrcamentoBean() {
System.out.println("Entrou no construtor");
orcamento = new Orcamento();
listarsitiacao = new HashMap<String, String>();
ListarSituacoes();
listarclientes = new ArrayList<Cliente>();
//carrinho
produtosSmall = new ArrayList<Produto>();
droppedProdutos = new ArrayList<Produto>();
}
@PostConstruct
public void Lista(){
listarclientes = clienteDao.BuscaTodosCliente();
//carrinho
produtosSmall = produtoDao.BuscaTodosProdutos();
}
public void ListarSituacoes(){
listarsitiacao.put("Ativo", "ativo");
listarsitiacao.put("Efetuado", "efetuado");
listarsitiacao.put("Cancelado", "cancelado");
}
public void salvar(ActionEvent event) {
System.out.println("Entrou no metodo salvar orcamento");
orcamentoDao.SalvaOrcamento(orcamento);
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, "Orcamento Realizado com Sucesso!", ""));
orcamento = new Orcamento();
}
public void onProdutoDrop(DragDropEvent ddEvent) {
Produto produto = ((Produto) ddEvent.getData());
droppedProdutos.add(produto);
produtosSmall.remove(produto);
}
public List<Cliente> getListarclientes() {
return listarclientes;
}
public void setListarclientes(List<Cliente> listarclientes) {
this.listarclientes = listarclientes;
}
public Orcamento getOrcamento() {
return orcamento;
}
public void setOrcamento(Orcamento orcamento) {
this.orcamento = orcamento;
}
public IOrcamento getOrcamentoDao() {
return orcamentoDao;
}
public void setOrcamentoDao(IOrcamento orcamentoDao) {
this.orcamentoDao = orcamentoDao;
}
public Cliente getClientes() {
return clientes;
}
public void setClientes(Cliente clientes) {
this.clientes = clientes;
}
public Map<String, String> getListarsitiacao() {
return listarsitiacao;
}
public void setListarsitiacao(Map<String, String> listarsitiacao) {
this.listarsitiacao = listarsitiacao;
}
public ICliente getClienteDao() {
return clienteDao;
}
public void setClienteDao(ICliente clienteDao) {
this.clienteDao = clienteDao;
}
public IProduto getProdutoDao() {
return produtoDao;
}
public void setProdutoDao(IProduto produtoDao) {
this.produtoDao = produtoDao;
}
public List<Produto> getProdutosSmall() {
return produtosSmall;
}
public void setProdutosSmall(List<Produto> produtosSmall) {
this.produtosSmall = produtosSmall;
}
public List<Produto> getDroppedProdutos() {
return droppedProdutos;
}
public void setDroppedPprodutos(List<Produto> droppedProdutos) {
this.droppedProdutos = droppedProdutos;
}
}
Alguem se talvez é algum bug do primefaces??? Ou é algo que estou fazendo errado na hora de montar o dataGrid???