2012-10-11 64 views
0

拖放,排序和排序對我來說工作正常,但過濾不能正常工作(過濾器只能工作一次)。如果有人獲得解決方案意味着善意幫助我。過濾器不適用於primefaces dataTable拖放

的index.xhtml

<?xml version='1.0' encoding='UTF-8' ?> 
<!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:h="http://java.sun.com/jsf/html"  
     xmlns:p="http://primefaces.org/ui"> 
    <h:head> 
     <script type="text/javascript"> 
      function handleDrop(event, ui) 
      { 
       var droppedCar = ui.draggable; 
       droppedCar.fadeOut('fast'); 
      } 
     </script> 
    </h:head> 
    <h:body> 
     <h:form id="carForm"> 
       <p:dataTable id="availableCars" var="car" value="#{Report.field1}"> 

        <p:column sortBy="#{car.values}" filterBy="#{car.values}" headerText="Properties"> 
           <h:outputText id="dragIcon" value="#{car.values}" /> 
           <p:draggable for="dragIcon" revert="true" /> 
          </p:column> 
       </p:dataTable>    
      <p:fieldset id="selectedCars" style="margin-top:20px"> 
        <p:outputPanel id="dropArea"> 
         <h:outputText value="!!!Drop here!!!" rendered="#{empty Report.field2}" style="font-size:24px;" /> 
         <p:dataTable var="car" value="#{Report.field2}" rendered="#{not empty Report.field2}"> 
           <p:column headerText="Color"> 
            <h:outputText value="#{car.values}" /> 
           </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="#{Report.onCarDrop}" update="dropArea availableCars" /> 
      </p:droppable> 
     </h:form> 
    </h:body> 
</html> 

和backbeans是

tempReport.java

public class tempReport 
{ 
    public String values; 
    public tempReport(String values) 
    { 
     this.values=values; 
    } 
    public String getValues() 
    { 
     return values; 
    } 
    public void setValues(String values) 
    { 
     this.values=values; 
    } 
} 

ReportGenerator.java

import java.io.Serializable; 
import java.util.ArrayList; 
import java.util.List; 
import javax.faces.bean.ManagedBean; 
import javax.faces.bean.RequestScoped; 
import org.primefaces.event.DragDropEvent; 
@ManagedBean(name="Report") 
@RequestScoped 
public class ReportGenerator implements Serializable 
{ 
    static List<tempReport> field1=new ArrayList<tempReport>(),field2=new ArrayList<tempReport>(); 
    static int i=1; 
    public ReportGenerator() 
    { 

     if(i==1) 
     { 
     field1=new ArrayList<tempReport>(); 
     field2=new ArrayList<tempReport>(); 
     field1.add(new tempReport("one")); 
     field1.add(new tempReport("two")); 
     field1.add(new tempReport("three")); 
     field1.add(new tempReport("four")); 
     field1.add(new tempReport("five")); 
     field1.add(new tempReport("six")); 
     i++; 
     } 
    } 
    public List<tempReport> getField1() 
    { 
     return field1; 
    } 
    public void setField1(List<tempReport> field1) 
    { 
     this.field1=field1; 
    } 
    public List<tempReport> getField2() 
    { 
     return field2; 
    } 
    public void setField2(List<tempReport> field2) 
    { 
     this.field2=field2; 
    } 
    public void onCarDrop(DragDropEvent ddEvent) 
    { 
     tempReport car = ((tempReport) ddEvent.getData()); 
     int x=0; 
     for(tempReport item: field2) 
     { 
      if(item==car) 
       x=1; 
     } 
     if(x==0) 
     field2.add(car);  
    } 
    } 

謝謝

回答

0

我回primefaces 3.3.1,因爲3.3.1以其優良的工作不是在3.4和3.4.1

工作謝謝

+1

你一定要報告問題在這裏:http://code.google.com/p/primefaces/issues/list – perissf

+0

謝謝@perissf,我在code.google.com/p/primefaces/issues/detail?id=4801中添加了我的問題 –

相關問題