我的数据表是可编辑的。当我编辑行时,来自旧数据但我需要新数据。
第一次观看:http://blog.kaykisiz.com/wp-content/uploads/2014/07/1.png
点击修改按钮:http://blog.kaykisiz.com/wp-content/uploads/2014/07/2.png
点击接受按钮:=> firstview
mypage.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/maintemplate.xhtml">
<ui:define name="content">
<p:panelGrid columns="2">
<h:outputText value="Dosya Adi" />
<h:outputText value="#{sessionController.messageFile.fileName}" />
<h:outputText value="Dosya Yolu" />
<h:outputText value="#{sessionController.messageFile.filePath}" />
</p:panelGrid>
<h:form id="formEdit">
<p:dataTable var="item"
value="#{messageFileDetailController.fileDetailList}" id="itemList"
paginator="true" scrollable="true" liveScroll="true" rows="25"
resizableColumns="true" paginatorAlwaysVisible="true"
scrollHeight="100%" editable="true" editMode="row" >
<f:facet name="header">Metin Listesi</f:facet>
<p:ajax event="rowEdit"
listener="#{messageFileDetailController.onRowEdit}" />
<p:column headerText="Baslik" filterBy="#{item.messageTitle}"
filterMatchMode="contains">
<h:outputText value="#{item.messageTitle}" style="font-weight:bolder" />
</p:column>
<p:column headerText="TR">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.messageTextTr}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{item.messageTextTr}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="EN">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.messageTextEn}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{item.messageTextEn}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="AR">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.messageTextAr}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{item.messageTextAr}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="KU">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.messageTextKu}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{item.messageTextKu}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:6%">
<p:rowEditor />
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
mycontroller.java
import java.io.Serializable;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.component.api.UIData;
import org.primefaces.event.RowEditEvent;
import tr.com.mergentech.web.devtool.controller.SessionController;
import tr.com.mergentech.web.devtool.dao.messages.IMessageFileDetailDao;
import tr.com.mergentech.web.devtool.entity.messages.MessageString;
@ManagedBean(name = "messageFileDetailController")
@ViewScoped
public class MessageFileDetailController implements Serializable {
private static final long serialVersionUID = -8484010295744327677L;
@ManagedProperty(value = "#{messageFileDetailDao}")
private IMessageFileDetailDao messageFileDetailDao;
@ManagedProperty(value = "#{sessionController}")
private SessionController sessionController;
public MessageFileDetailController() {
}
public IMessageFileDetailDao getMessageFileDetailDao() {
return messageFileDetailDao;
}
public void setMessageFileDetailDao(
IMessageFileDetailDao messageFileDetailDao) {
this.messageFileDetailDao = messageFileDetailDao;
}
public SessionController getSessionController() {
return sessionController;
}
public void setSessionController(SessionController sessionController) {
this.sessionController = sessionController;
}
public List<MessageString> getFileDetailList() throws Exception {
return getMessageFileDetailDao().getMessageFileDetail(
sessionController.getMessageFile());
}
public void onRowEdit(RowEditEvent event) throws Exception {
MessageString message = ((MessageString) (event.getObject()));
System.out.println(message.getId() + " - "
+ message.getMessageTextEn() + " - "
+ message.getMessageTextKu());
getMessageFileDetailDao().update(message, message.getId());
}
}
mylog文件:
2014-07-17T16:15:41.642+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:15:41.690+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.771+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.791+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.804+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.830+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.841+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.857+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.868+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.882+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.895+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.905+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.915+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.924+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.932+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.944+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.954+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.965+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:42.973+0300|Info: 6 - Department of Expenditure Input -
2014-07-17T16:16:42.981+0300|Info: Hibernate: select messagestr0_.ID as ID1_3_0_, messagestr0_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, messagestr0_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, messagestr0_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, messagestr0_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, messagestr0_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, messagestr0_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING messagestr0_ where messagestr0_.ID=?
2014-07-17T16:16:43.123+0300|Info: Hibernate: update MESSAGE_STRING set MESSAGE_FILE_ID=?, MESSAGE_TEXT_AR=?, MESSAGE_TEXT_EN=?, MESSAGE_TEXT_KU=?, MESSAGE_TEXT_TR=?, MESSAGE_TITLE=? where ID=?
2014-07-17T16:16:43.138+0300|Info: Hibernate: select messagestr0_.ID as ID1_3_0_, messagestr0_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, messagestr0_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, messagestr0_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, messagestr0_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, messagestr0_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, messagestr0_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING messagestr0_ where messagestr0_.ID=?
2014-07-17T16:16:43.162+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:43.175+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:52.334+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
2014-07-17T16:16:52.352+0300|Info: Hibernate: select this_.ID as ID1_3_0_, this_.MESSAGE_FILE_ID as MESSAGE_2_3_0_, this_.MESSAGE_TEXT_AR as MESSAGE_3_3_0_, this_.MESSAGE_TEXT_EN as MESSAGE_4_3_0_, this_.MESSAGE_TEXT_KU as MESSAGE_5_3_0_, this_.MESSAGE_TEXT_TR as MESSAGE_6_3_0_, this_.MESSAGE_TITLE as MESSAGE_7_3_0_ from MESSAGE_STRING this_ where (this_.MESSAGE_FILE_ID=?) order by this_.MESSAGE_TITLE asc
答案 0 :(得分:2)
您的问题与Primefaces行编辑无关。我查看并测试了您的xhtml代码并正常工作。 您正在收到RowEditEvent事件&#39;对象值正确。所以也许你的问题在你的dao包中,并且可能不会将更改提交到数据库。在Jsf页面和类中没有问题。