0
不選擇當我選擇在數據表中它不是在需要文本框中Fields.i顯示一排不知道是什麼問題數據表在JSF
當我選擇在數據表中的行是不顯示在需要的文本框中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;
}
}