当我尝试删除数据表中的现有行时,它已成功删除。但是,一旦我尝试在同一会话中添加新行,它就会编辑表格中的最后一行,但它已经添加到列表中。
<p:dataTable id="AllData" var="itemTypeVar" value="#{itemTypeBean.itemTypesList}" sortBy="#{itemTypeVar.itemTypeId}"
editable="true" paginator="#{common.paginator}" rows="#{common.rows}"
paginatorTemplate="#{common.paginatorTemplate}"
rowsPerPageTemplate="#{common.rowsPerPageTemplate}"
paginatorPosition="#{common.paginatorPosition}" styleClass="sClass ui-datatable-hor-scroll"
widgetVar="allData">
<p:column headerText="#{docBundle.delete}" style=" height: auto;width:60px;text-align: center;">
<p:commandLink action="#{itemTypeBean.delete(itemTypeVar)}" update=":Form_Data:AllData :Form_Mesages" oncomplete="PF('allData').clearFilters()" />
<p:commandButton actionListener="#{itemTypeBean.addRecord}" id="add" value= "#{docBundle.add}" update=":Form_Data :Form_Mesages" style="margin-top: 5px;" oncomplete="jQuery('.ui-datatable-data tr').last().find('span.ui-icon-pencil').each(function(){jQuery(this).click()}); " />
豆:
public void delete(InvStpItemType deleted) {
RequestContext context = RequestContext.getCurrentInstance();
itemStpTypeCurrent = new InvStpItemType();
itemStpTypeCurrent = deleted;
try
{
if (itemStpTypeCurrent.getItemTypeId() != 0) {
invStpItemTypeFacade.remove(deleted);
itemTypesList.remove(itemStpTypeCurrent);
Messages.deleteSuccMsg(this.getLanguage());
} else {
itemTypesList.remove(itemStpTypeCurrent);
}
}
catch(Exception ex)
{
Messages.errorMsg(getLang(), "canNotDeletedUsedByItems");
}
}
public void addRecord() {
if (!addRecord) {
addRecord = true;
itemStpTypeCurrent = new InvStpItemType();
itemStpTypeCurrent.setActive("A");
itemTypesList.add(itemStpTypeCurrent);
Utilities.getLastPagination(":Form_Data:AllData");
}
else{ Utilities.getLastPagination(":Form_Data:AllData");}
}
答案 0 :(得分:0)
我从我的XHTML代码中删除了'oncomplete =“PF('allData')。clearFilters()”'并从我的Bean代码重置数据表,它运行良好...如果你有更好的解决方案,请不要犹豫发布它。
DataTable dataTable = (DataTable)FacesContext.getCurrentInstance().getViewRoot().findComponent(":Form_Data:AllData");
dataTable.reset();