I want to process this form (valueChangueListener is not valid in the real case).
This is the flip side of the bean:
private List<Management> managements; //getters setters protected static final Logger logger = Utils.loggerForThisClass(); @PostConstruct public void init() { TreeNode root1 = new DefaultTreeNode("root", null); TreeNode root2 = new DefaultTreeNode("root", null); TreeNode root3 = new DefaultTreeNode("root", null); TreeNode child1 = new DefaultTreeNode(new Element("Total"), root1); TreeNode child2 = new DefaultTreeNode(new Element("Total"), root2); TreeNode child3 = new DefaultTreeNode(new Element("Total"), root3); new DefaultTreeNode(new Element("Office"), child1); new DefaultTreeNode(new Element("Office"), child2); new DefaultTreeNode(new Element("Office"), child3); managements = new ArrayList<Management>(); managements.add(new Management("Company1", root1)); managements.add(new Management("Company2", root2)); managements.add(new Management("Company3", root3)); } public void saveAction() { StringBuilder textToShowInMessage = new StringBuilder(); for (Management management : managements) { for (TreeNode children : management.getElementTree().getChildren()) { logger.debug(management.getTabTitle() + "->" + ((Element) children.getData()).getName() + "->" + ((Element) children.getData()).getValue()); for (TreeNode leaf : children.getChildren()) { logger.debug(management.getTabTitle() + "->" + ((Element) leaf.getData()).getName() + "->" + ((Element) leaf.getData()).getValue()); } } } } ...
And models:
public class Management { private String tabTitle; private TreeNode elementTree; public Management(String tabTitle, TreeNode elementTree) { super(); this.tabTitle = tabTitle; this.elementTree = elementTree; } public TreeNode getElementTree() { return elementTree; } public void setElementTree(TreeNode elementTree) { this.elementTree = elementTree; } public String getTabTitle() { return tabTitle; } public void setTabTitle(String tabTitle) { this.tabTitle = tabTitle; } public class Element { private String name; private String value; public Element(String name) { super(); this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getValue() { return value; } public void setValue(String value) { this.value = value; }
Finally, the view:
<h:form> <p:tabView var="management" value="#{testBean.managements}"> <p:tab title="#{management.tabTitle}"> <p:treeTable value="#{management.elementTree}" var="element" resizableColumns="true"> <p:column> <f:facet name="header"> Name </f:facet> #{element.name} </p:column> <p:column> <f:facet name="header"> Value </f:facet> <h:inputText value="#{element.value}" /> </p:column> </p:treeTable> </p:tab> </p:tabView> <p:commandButton value="#{msg.save}" action="#{testBean.saveAction}" process="@all" icon="ui-icon-disk" update="@form" /> </h:form>
I want to handle all form values inside a TreeNode. But only the first tab and value are returned to the Backing bean.
This is intput:



This is the conclusion:
DEBUG: com.smf.web.jsf.bean.TestBean - Company1->Total->1 DEBUG: com.smf.web.jsf.bean.TestBean - Company1->Office->null DEBUG: com.smf.web.jsf.bean.TestBean - Company2->Total->null DEBUG: com.smf.web.jsf.bean.TestBean - Company2->Office->null DEBUG: com.smf.web.jsf.bean.TestBean - Company3->Total->null DEBUG: com.smf.web.jsf.bean.TestBean - Company3->Office->null
I tested with process = "@all" and @form ... and always had the same result
We can divide the problem into two parts:
1. Only the first tab is processed. 2. Only the first value of the tree is processed.
Perhaps the reason for both is the same.
Let the resolution begin ( The values of h: inputText inside p: treeTable are not processed ).