拖放,排序和排序工作正常,但过滤不正常(过滤器只工作一次)。如果任何人得到解决方案,请帮助我。
的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 :(得分:0)
我回到了主题3.3.1,因为它在3.3.1中的精细工作不适用于3.4和3.4.1
谢谢