How to make binding of value in datatable when select mode = multiple

I need an explanation for binding the below value in the outputText dialog inside p :. I don't understand what is and if there is another way.

In my example: I tried, if I select one or more checkboxes, the value gets bound, but when I click the root button that is used to select all checkboxes, its selection will be selected, but the values ​​are not saved at the end.

  

<p:dataTable id="checkboxDT" 
             var="car" 
             value="#{dtSelectionView.cars6}" 
             selection="#{dtSelectionView.selectedCars}" 
             rowKey="#{car.id}" 
             style="margin-bottom:0">
    <f:facet name="header">
        Checkbox
    </f:facet>
    <p:column selectionMode="multiple" 
              style="width:16px;text-align:center"/>
    <p:column headerText="Id">
        <h:outputText value="#{car.id}" />
    </p:column>
    <p:column headerText="Year">
        <h:outputText value="#{car.year}" />
    </p:column>
    <p:column headerText="Brand">
        <h:outputText value="#{car.brand}" />
    </p:column>
    <p:column headerText="Color">
        <h:outputText value="#{car.color}" />
    </p:column>
    <f:facet name="footer">
        <p:commandButton process="checkboxDT" 
                         update=":form:multiCarDetail" 
                         icon="ui-icon-search" 
                         value="View" 
                         oncomplete="PF('multiCarDialog').show()" />
    </f:facet>
</p:dataTable>



<p:dialog header="Selected Cars" 
          widgetVar="multiCarDialog" 
          modal="true" 
          showEffect="fade" 
          hideEffect="fade" 
          resizable="false" 
          width="200">
    <p:outputPanel id="multiCarDetail" style="text-align:center;">
        <ui:repeat value="#{dtSelectionView.selectedCars}" 
                   var="car">

            <h:outputText value="#{car.id} - #{car.brand}" 
                          style="display:block"/>
        </ui:repeat>
    </p:outputPanel>
</p:dialog>

      

+3


source to share


1 answer


You must update the checkboxDT as the update is used to determine the IDs of the components to be updated (updated with updated values ​​from the server). If you don't update checkboxDT, the selected maps are not updated either.



<p:commandButton process="checkboxDT" 
                 update="checkboxDT,:form:multiCarDetail" 
                 icon="ui-icon-search" 
                 value="View" 
                 oncomplete="PF('multiCarDialog').show()" />

      

+1


source







All Articles