TreeTable: CellEdit event not working for dynamic columns
See original GitHub issueI retested https://github.com/primefaces/primefaces/issues/4724. successfully with 8.0-SNAPSHOT for p:dataTable
. However, p:treeTable
does not work. Here is the sample for p:treeTable:
Bean3.java
@SessionScoped @Named
public class Bean3 implements Serializable {
private static final long serialVersionUID = 1L;
public class Test implements Serializable { // Content class of TreeNodes
private static final long serialVersionUID = 1L;
public String value;
public String getValue() { return value; }
public void setValue(String value) { this.value = value; }
public int index;
public int getIndex() { return index; }
public void setIndex(int index) { this.index = index; }
public Test(String value, int index) { this.value=value; this.index=index; }
}
TreeNode root;
public TreeNode getRoot() { return root; }
public void setRoot(TreeNode root) { this.root = root; }
public void createTreeNodes() {
root=new DefaultTreeNode(new Test("Root", 0), null);
new DefaultTreeNode(new Test("One", 1), root);
new DefaultTreeNode(new Test("Two", 2), root);
}
@PostConstruct public void init() { createTreeNodes(); }
public void onCellEdit(CellEditEvent<?> e) { info("cellEdit", e); }
public void onCellEditInit(CellEditEvent<?> e) { info("cellEditInit", e); }
public void onCellEditCancel(CellEditEvent<?> e) { info("cellEditCancel", e); }
public static void info(String method, CellEditEvent<?> e) {
String message=String.format("old=%s, new=%s", e.getOldValue(), e.getNewValue());
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO, method+":", message));
}
}
treeTable.xhtml
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:p="http://primefaces.org/ui" >
<h:head />
<h:body>
<h:form id="form">
<p:growl id="msgs" showDetail="true"/>
<p:treeTable value="#{bean3.root}" var="var" editMode="cell" editable="true" tableStyle="width:auto">
<p:ajax event="cellEditInit" listener="#{bean3.onCellEditInit}" update=":form:msgs"/>
<p:ajax event="cellEdit" listener="#{bean3.onCellEdit}" update=":form:msgs"/>
<p:columns var="property" value="#{['value','index']}" headerText ="#{property}">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{var[property]}" /></f:facet>
<f:facet name="input"><p:inputText value="#{var[property]}" /></f:facet>
</p:cellEditor>
</p:columns>
</p:treeTable>
</h:form>
</h:body>
</html>
Reproduce
- Click in the top/left cell and change the value. It will not change (bug).
- The message shows
cellEdit: old=One, new=One
, butnew
should be changed. - Also, cellEditInit is not fired for treeTable (but for dataTable)
- The message shows
- Hovever, in the second row, it works
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
CellEditor: Dynamic columns cellEdit event - Bountysource
The components p:dataTable and p:treeTable both have the following problem: 1) Environment. All PF, browser and AppServer versions ...
Read more >Angular: Call method on edit cell event PrimeNG TreeTable
I have a PrimeNG TreeTable with an editable column ...
Read more >cell editing problem for dynamic columns - PrimeFaces forum
Hi, I am using Primefaces 5.3, JSF 2.2, Tomcat 8. getOldValue and getNewValue methods return null value after cell editing. Why? Thanks in ......
Read more >Angular PrimeNG TreeTable Dynamic Columns
Angular PrimeNG TreeTable Dynamic Columns is used to set and render the columns of the TreeTable component Dynamically.
Read more >primefaces - issue #5103 - Google Code
And on node select childrens of a that Node can be loaded dynamically from datasource, like remote or database. Problem is the user ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
OK I merged the CellEditInit event fix but reopened this ticket since the CellEdit issue is not resolved.
So I fixed the treetable CellEditInit event issue. But still working on the CellEdit event. It is so werid it only happens on the first cell but row 2 it works fine.