我正在使用Prime面部3.5.8,我正在获取具有行编辑事件的重复行。我的行计数很好但是一条记录显示两次而不是其他。这是我在调用我的clintList加载时得到的。当我关闭对话框并打开它时,它很好,即使我检查了我的列表它正在获得正确的数据,在此先感谢..
我的BeanCode用于编辑,
public void onClientEdit(RowEditEvent event) {
try {
Client edtClient = (Client) event.getObject();
if (null == edtClient.getClientName()
|| edtClient.getClientName() == "") {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
CommonStringUtil.getUIString("clintNameEmpty"),
CommonStringUtil.getUIString("clintNameEmpty")));
getAgencyClients();
return;
}
HibernateUtil.beginTransaction();
Agency tempAgency = agencyHome.findById(agency.getAgencyId());
Hibernate.initialize(tempAgency.getClients());
HibernateUtil.commitTransaction();
for (Client cl : (Set<Client>) tempAgency.getClients()) {
if (cl.getClientName().equalsIgnoreCase(
edtClient.getClientName().trim())) {
log.debug("Client Name Already exists");
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_WARN,
CommonStringUtil
.getUIString("clientNameExists"),
CommonStringUtil
.getUIString("clientNameExists")));
getAgencyClients();
return;
}
}
HibernateUtil.beginTransaction();
Client eClient = clientHome.findById(edtClient.getClientId());
eClient.setClientName(edtClient.getClientName());
clientHome.attachDirty(eClient);
clientName = null;
agencyHome.attachDirty(agency);
HibernateUtil.commitTransaction();
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_INFO, CommonStringUtil
.getUIString("clientNameEditSucc"), CommonStringUtil
.getUIString("clientNameEditSucc")));
} catch (Exception e) {
if (HibernateUtil.isTransactionActive())
HibernateUtil.rollbackTransaction();
log.error("Error Updating Client Name", e);
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, CommonStringUtil
.getUIString("clientNameEditFail"), CommonStringUtil
.getUIString("clientNameEditFail")));
}
}
My View Part
<p:dialog widgetVar="clientDialogue" modal="true" id="clientdilogId"
showHeader="false" style="padding:0;">
<h:form id="clientDlgForm">
<p:toolbar style="height:38px;">
<p:toolbarGroup align="left">
<h:outputText
value="Edit Client Messages: #{adminAgencyBean.agencyName}"
styleClass="dialog-header-Text" style="line-height:38px"></h:outputText>
</p:toolbarGroup>
<p:toolbarGroup align="right" style="margin-left:50px;">
<p:inputText value="#{adminAgencyBean.clientName}" id="clientName"
maxlength="45" />
<p:spacer width="5"></p:spacer>
<p:commandButton action="#{adminAgencyBean.createClient}"
icon="ui-icon-custom-arrow" iconPos="right" value="Create"
style="margin-left:5px;margin-right:20px;" update="@form" />
<p:commandLink value="X" onclick="clientDialogue.hide()"
style="text-decoration:none;margin-right:10px;" process="@none"></p:commandLink>
</p:toolbarGroup>
</p:toolbar>
<p:messages id="clientMsgs" />
<p:scrollPanel style="width:980px;height:400px;width:100%;"
mode="native">
<p:dataTable value="#{adminAgencyBean.clientList}" var="client"
sortBy="#{client.clientName}" sortOrder="ascending" editable="true"
id="ClientTable">
<p:ajax event="rowEdit" listener="#{adminAgencyBean.onClientEdit}"
update=":clientDlgForm:clientMsgs"/>
<p:ajax event="rowEditCancel" />
<p:column headerText="Client Name" sortBy="#{client.clientName}"
style="white-space:pre-line;width:130px;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.clientName}" />
</f:facet>
<f:facet name="input">
<p:inputText id="editClientName" value="#{client.clientName}"
maxlength="45" style="width:90px"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Edit Client"
style="white-space:pre-line;width:80px;">
<p:rowEditor
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] lt 1}" />
<h:outputText value="#{commonmessages.NoEdit}"
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] ge 1}" />
</p:column>
<p:column headerText="Remove Client"
style="width:85px;white-space:pre-line">
<p:commandButton value="Remove"
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] lt 1}"
action="#{adminAgencyBean.deleteClient}" update="@form"
process="@none" styleClass="blue_button">
<f:setPropertyActionListener target="#{adminAgencyBean.clientId}"
value="#{client.clientId}"></f:setPropertyActionListener>
</p:commandButton>
<h:outputText value="#{commonmessages.nodelete}"
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] ge 1}" />
</p:column>
</p:dataTable>
</p:scrollPanel>
</h:form>
</p:dialog>