【发布时间】:2013-12-07 12:21:51
【问题描述】:
我正在使用 primefaces 开发 JSF,我使用的是 dataTable row Editing,其中包含来自数据库的数据,
问题
- 编辑行后,我曾经从表中删除行,但 dataTable 显示的是剩余记录的副本,
例如:
JSF 页面:
<p:dataTable var="perreq" value="#{leaverequest.perRequestList}" id="perrequestlist" editable="true" >
<p:ajax event="rowEdit" update=":form0:form2:acivitydatatable,perrequestlist,:form0:form:growl" listener="#{leaverequest.onEdit}" />
<p:ajax event="rowEditCancel" listener="#{leaverequest.onCancel}" />
<p:column headerText="Name" style="width:100px;"><h:outputText value="#{perreq.ename}" /></p:column>
<p:column headerText="From" style="width:60px;"><h:outputText value="#{perreq.perFrom}" /></p:column>
<p:column headerText="To" style="width:60px;"><h:outputText value="#{perreq.perTo}"/></p:column>
<p:column headerText="Date" style="width:80px;">
<h:outputText value="#{perreq.dateOfPermission}" >
<f:convertDateTime pattern="dd-MM-yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Reason" style="width:200px;"><h:outputText value="#{perreq.reason}" /></p:column>
<p:column headerText="Tl Comments" style="width:200px;"><h:outputText value="#{perreq.tlComments}" /></p:column>
<p:column headerText="Comments" style="width:160px;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{leaverequest.perComments}" style="width:150px;" label="Year" maxlength="100"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Status" style="width:70px;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{perreq.status}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{leaverequest.statusResult}" style="width:100px;" >
<f:selectItem itemLabel="Accept" itemValue="Accepted"/>
<f:selectItem itemLabel="Reject" itemValue="Rejected"/>
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column >
<p:column width="80px;"><p:rowEditor/></p:column>
</p:dataTable>
带有 getter n setter 的 Bean:
public void onEdit(RowEditEvent event)
{
getPendingPermssionRequestDB();
}
public List<PendingRequestBean> getPerRequestList()
{
return perRequestList;
}
public void setPerRequestList(List<PendingRequestBean> perRequestList)
{
this.perRequestList = perRequestList;
}
public void getPendingPermssionRequestDB()
{
try
{
//Modify list and retrieve from DB
Session hibernateSession=HibernateUtil.getSessionFactory().openSession();
Query query=hibernateSession.createQuery("select a from Permissionrecord as a");
List<PendingRequestBean> l=(List<PendingRequestBean>)query.list();
this.perRequestList=l;
hibernateSession.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
任何建议...
【问题讨论】:
-
实际上提供一些代码比显示正在发生的事情的图片更有帮助。
-
我已经添加了相应的 bean 类的 JSF 代码,