0

I want to process this form (valueChangueListener is not valid in real case).

This is the back 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 process all form values inside TreeNode also. But only first tab and value is recived in Backing bean.

This is the intput:

Frist Tab Second Tab Third Tab

This is the output:

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 ever the same result

We can divide the problem in two:

1.Only is processed the first Tab. 2.Only the first value of tree is processed.

Maybe the reason of both is the same.

Let's start resolving (Values of h:inputText inside p:treeTable are not processed).

4

0 回答 0