当我在数据表中选择一行时,它没有显示在必需的文本框中字段中。我不知道是什么问题
当我在数据表中选择一行时,它没有显示在必需的文本框中字段中。我不知道是什么问题
我的数据表
<p:dataTable
var="op"
value="#{Bean.datamodel}"
paginator="true"
rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="2,5,10,15"
selectionMode="single"
lazy="true"
selection="#{Bean.dto}"
id="customerSearchTable"
emptyMessage="No Customers found with given criteria"
resizableColumns="true"
widgetVar="dataTab">
<p:tooltip
for="customerSearchTable"
value="Select a customer to update the details" />
<p:ajax
event="rowSelect"
update=":name:display" />
<f:facet name="header">
Letter of Promotion
</f:facet>
<p:column
headerText=" Id"
sortBy="#{op.id}"
width="100"
filterBy="#{op.id}"
filterMatchMode="contains">
<h:outputText value="#{op.id}" />
</p:column>
<p:column
headerText="Empno"
sortBy="#{op.empno}"
filterBy="#{op.empno}"
filterMatchMode="contains">
<h:outputText value="#{op.empno}" />
</p:column>
<p:column
headerText="De"
sortBy="#{op.de}"
filterBy="#{op.de}"
filterMatchMode="contains">
<h:outputText value="#{op.de}" />
</p:column>
<p:column
headerText="Empname"
sortBy="#{op.empname}"
filterBy="#{op.empname}"
filterMatchMode="contains">
<h:outputText value="#{op.empname}" />
</p:column>
<p:column
headerText="De"
sortBy="#{op.de}"
filterBy="#{op.de}"
filterMatchMode="contains">
<h:outputText value="#{op.de}" />
</p:column>
<p:column
headerText="Lo"
sortBy="#{op.lo}"
filterBy="#{op.lo}"
filterMatchMode="contains">
<h:outputText value="#{op.lo}" />
</p:column>
<f:facet name="footer">
In total there are #{Bean.datamodel.rowCount}
</f:facet>
数据模型
import java.io.Serializable;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;
public class Datamodel extends ListDataModel<DTO> implements SelectableDataModel<DTO>, Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
public Datamodel(List<DTO> list) {
super(list);
// TODO Auto-generated constructor stub
}
@Override
public DTO getRowData(String rowKey) {
// TODO Auto-generated method stub
@SuppressWarnings("unchecked")
List<DTO> points = (List<DTO>)getWrappedData();
if (rowKey != null && rowKey.trim().length() != 0 && !rowKey.equalsIgnoreCase("null")) {
for (DTO point : points) {
if (point.getEmpname().equals(rowKey)) {
return point;
}
}
}
return null;
}
@Override
public Object getRowKey(DTO arg0) {
// TODO Auto-generated method stub
return null;
}
}