f:setPropertyActionListener inside p:ajax for p:tree

UI Components for JSF
Post Reply
Soupdragon
Posts: 16
Joined: 22 Jul 2011, 10:50

27 Jul 2011, 12:51

I have a tree which, when a row is selected, should pass a value to a couple of other facelets controlled by different backing beans. In 3.0m tree selection is now handled by p:ajax, which seems like a good idea. The listener works as expected but setPropertyActionListeners inside the p:ajax don't seem to be working.

If I add a p:commandButton with the same setPropertyActionListeners it works as expected. I've put breakpoints in the getter for #{flaggedSuppliers.selectedSupplier} and it's not called on the node selection, but it is called twice, as expected, when the command button is clicked.

Here's the key part of the facelet. Note that the onNodeSelected sets the appropriate value of selectedSupplier in the backing bean.

Code: Select all

                </p:treeNode>
                <p:ajax event="select" listener="#{flaggedSuppliers.onNodeSelected}"  update="supEditPanel,:invForm:supInvoicesPanel">
                    <f:setPropertyActionListener target="#{supEdit.supplier}" value="#{flaggedSuppliers.selectedSupplier}"/>
                    <f:setPropertyActionListener target="#{invoiceTree.supplier}" value="#{flaggedSuppliers.selectedSupplier}"/>
                </p:ajax>
            </p:tree>
            <p:commandButton value="Refresh" action="#{flaggedSuppliers.refresh}"
                             update="flaggedTree" ajax="true"/>
            <p:commandButton value="Details" ajax="true" update="supEditPanel,:invForm:supInvoicesPanel">
                    <f:setPropertyActionListener target="#{supEdit.supplier}" value="#{flaggedSuppliers.selectedSupplier}"/>
                    <f:setPropertyActionListener target="#{invoiceTree.supplier}" value="#{flaggedSuppliers.selectedSupplier}"/>
                
            </p:commandButton>


cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

27 Jul 2011, 13:13

I don't think f:setPropertyActionListener is supported in tree.

Soupdragon
Posts: 16
Joined: 22 Jul 2011, 10:50

27 Jul 2011, 14:42

I would assume any implementation needed to access these actionListeners would be common code relating to p:ajax, whatever structure it was enclosed in. I notice that f:ajax gives a definite error message if you put setPropertyActionListener elements in it.

I think I've found a work-arround, setting the other beans from the backing bean like this:

Code: Select all

            selectedSupplier = ps.getSupplier();
            ELContext eLContext = FacesContext.getCurrentInstance().getELContext();
            ELResolver elr = eLContext.getELResolver();
            SupplierEditBean seBean = (SupplierEditBean)elr.getValue(eLContext, null, "supEdit");
            InvoiceManagementBean imBean = (InvoiceManagementBean) elr.getValue(eLContext, null, "invoiceTree");
            seBean.setSupplier(selectedSupplier);
            imBean.setSupplier(selectedSupplier);

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 35 guests