1

I am using Primefaces 5.0 and JSF 2.0.

Hello I have a defined as follows:

<p:dataTable id="activePackagesBeanTable"
                            value="#{packageManagerLocal_GetAllPackages.reviewList}"
                            var="activePkg"
                            selection="#{packageManagerLocal_GetAllPackages.selectedPackages}"
                            rowKey="#{activePkg.hashCode()}">
                            <p:ajax event="rowSelectCheckbox" update=":mainPanel:delegateButtonForm" />
                            <p:ajax event="rowUnselectCheckbox" update=":mainPanel:delegateButtonForm" />
                            <p:ajax event="toggleSelect" update=":mainPanel:delegateButtonForm" />
                            <p:column selectionMode="multiple" style="width:16px;text-align:center"/>
</p:dataTable>

and a that performs an action on that selection list and is defined as follows:

<p:commandButton id="delegateDoAction1" styleClass="button_blue"
                            type="submit" ajax="false" immediate="true" value="Delegate"
                            action="#{packageManagerLocal_GetAllPackages.reassign}"
                            title="#{hints_bundle['button.package.reassign']}"
                            execute="activePackagesBeanTable">
                        </p:commandButton>

Inside the backing bean, I have the function reassion() defined as follows.

List<MyObject> selectedPackages;

// Getters and setters for selectedPackages
.....
public String reassign() {
    String method = "reassign";
    logger.entering(this.getClass().getName(), method);
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("packageList", getSelectedPackages());
    logger.entering(this.getClass().getName(), method, "SWITCH");
    return "reassign";
}

However, when I debug with Eclipse my getter is returning a null value for selectedPackages? Why is that? What am I doing wrong?

  • I have changed the selectedPackages value from List to a regular array but I still get it null. – user3757114 Mar 11 '16 at 17:06
  • Next time, please create an [mcve]....The code you posted has no indication of the solution you posted so we can never tell and/or help. – Kukeltje Mar 11 '16 at 18:57

1 Answers1

0

I found the solution. The commandbutton and the dataTable need to be in the same form for the list to update.