当我在数据表中选择一行时,它不会显示在必填文本框中Fields.i不知道是什么问题
当我在数据表中选择一行时,它不会显示在必填文本框中Fields.i不知道是什么问题
MY DATATABLE
<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;
}
}
答案 0 :(得分:0)
解决此问题的方法是
Datamodel中的空构造函数
public Datamodel() {
super();
// TODO Auto-generated constructor stub
}
Datamodel中的返回值
public Object getRowKey(dto point) {
// TODO Auto-generated method stub
return point.getid();
}