पूर्ण होने पर पूरे
यहाँ JSF पेज है:
<h:form id="testForm">
<p:outputPanel id="testContainer">
<p:dataTable id="testTable" value="#{tableBean.data}" var="entry" editable="true" editMode="cell">
<p:ajax event="cellEdit" listener="#{tableBean.onCellEdit}" update=":testForm:testContainer" />
<p:column headerText="Col1">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{entry.col1}" /></f:facet>
<f:facet name="input"><p:inputText value="#{entry.col1}" /></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Col2">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{entry.col2}" /></f:facet>
<f:facet name="input"><p:inputText value="#{entry.col2}" /></f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
<p:commandButton id="refreshButton" value="Redisplay" update="testContainer" />
</p:outputPanel>
</h:form>
और यहाँ समर्थन सेम है:
@ManagedBean(name = "tableBean", eager = false)
@ViewScoped
public class TableBean {
public TableBean() {
RowData entry = new RowData("a1", "b1");
entries.add(entry);
entry = new RowData("a2", "b2");
entries.add(entry);
entry = new RowData("a3", "b3");
entries.add(entry);
}
public class RowData {
private String col1;
private String col2;
public RowData(String col1, String col2) {
this.col1 = col1;
this.col2 = col2;
}
public String getCol1() {
return col1;
}
public void setCol1(String col1) {
this.col1 = col1;
}
public String getCol2() {
return col2;
}
public void setCol2(String col2) {
this.col2 = col2;
}
}
private ArrayList<RowData> entries = new ArrayList<RowData>();
public List<RowData> getData() {
return entries;
}
public void onCellEdit(CellEditEvent event) {
entries.get(event.getRowIndex()).setCol1("Dummy Col 1");
entries.get(event.getRowIndex()).setCol2("Dummy Col 2");
}
}
जब अद्यतन = सहित ": testForm: testContainer" cellEdit AJAX घटना के भीतर, एक सेल मूल्य हटाए गए बदलते स्क्रीन पर डेटाटेबल और केवल सेल सामग्री (बटन के साथ) प्रस्तुत करता है - मुझे समझ में नहीं आता कि यह क्यों है। जब अद्यतन विशेषता निर्दिष्ट नहीं होती है, तो तालिका सक्रिय सेल के साथ स्क्रीन पर बनी रहती है, लेकिन अन्य कोशिकाओं में से कोई भी अपडेट नहीं किया जाता है (जैसा कि उम्मीद की जा सकती है)।
वांछित व्यवहार AJAX सेल एडिट ईवेंट के भीतर अद्यतन विशेषता निर्दिष्ट नहीं करके और सेल के मान को संपादित करने के बाद Redisplay बटन पर क्लिक करके प्राप्त किया जा सकता है (एक गैर-स्वचालित तरीके से)। मैं इसे स्वचालित तरीके से कैसे प्राप्त कर सकता हूं, और अपडेट विशेषता क्यों काम नहीं करती है?
मैं प्राइमफ़ेस 4.0 का उपयोग कर रहा हूं।
क्या आपने अद्यतन = ": testForm: testContainer" को अद्यतन = ": testForm: testTable" को बदलने का प्रयास किया है? –
अभी कोशिश की है, लेकिन केवल वर्तमान सेल अपडेट हो रहा है। – Franzl