PrimeFacesのインプレース編集機能を使用して行を編集すると、変更が適用されないようです。ここでPrimeFacesの1ページあたりの行数を変更した後のデータテーブルの奇妙な動作
は私のコードです:
properties.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<f:event type="javax.faces.event.PreRenderViewEvent" listener="${propertyManagedBean.preRenderView}"/>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Properties</title>
</h:head>
<h:body>
<div id="content" class="left_content">
<h:form>
<p:dataTable id="tbl" var="property" value="#{propertyManagedBean.properties}" paginator="true" rows="10" rowsPerPageTemplate="5,10,20">
<p:ajax event="rowEdit" update="@this" listener="#{propertyManagedBean.propertyRowEdit}"/>
<f:facet name="header">
Properties Manager
</f:facet>
<p:column headerText="Key" >
<h:outputText value="#{property.propKey}" />
</p:column>
<p:column headerText="Value">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{property.propValue}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{property.propValue}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options" style="width:15px">
<p:rowEditor />
</p:column>
</p:dataTable>
</h:form>
</div>
</h:body>
</html>
PropertyManagedBean.java
@ManagedBean
@SessionScoped
public class PropertyManagedBean {
private PropertyJpaController controller;
private List<Property> properties;
/** Creates a new instance of propertyManagedBean */
public PropertyManagedBean() {
controller = new PropertyJpaController();
extractProperties();
}
public void propertyRowEdit(RowEditEvent event) {
Property prop = (Property) event.getObject();
try {
controller.update(prop);
} catch (Exception ex) {
//TODO: Customize work with exceptions
}
extractProperties();
}
public List<Property> getProperties() {
return properties;
}
public void preRenderView() {
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
}
private void extractProperties() {
properties = controller.findPropertyEntities();
}
}
問題は、ページ上の行のプロパティを編集した後に起こりました。この行を変更すると、テーブルのプロパティの古い値が取得されます。
AS JBossでPrimeFaces 3rc2でところで試験しました。 –
私はそれを試してみましたが、DBテーブルに何も起こりません。 – Nazar