Good morning,
This is my code:
public void seleccionarTodos(AjaxBehaviorEvent event){
if(isIsSelectedAll()==true){
this.selectedFuentes=fuente;
setIsSelectedAll(false);
}else{
this.selectedFuentes.clear();
setIsSelectedAll(false);
}
}
I have a table with a general checkbox that when pressed I will select all the data contained in the table (the table contains a page)
then when I do the first search, it shows me the data (the data are selected by default)
When I click on the general checkbox it works fine, but if I leave deselected the data and made another search, it will show the data selected by default but at the moment of clicking the checkbox to deselect them, something very strange happens (the data is deselected and they are again selected) and I do not know what to do.
This is the code of the table:
<p:dataTable id="datos" var="f" rowKey="#{f.num}"
resizableColumns="true" value="#{busquedaBean1.fuente}"
selection="#{busquedaBean1.selectedFuentes}" style="margin-bottom:0;margin-top: 0%;"
rows="11" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" >
<!-- CONTENIDO DE LA TABLA -->
<p:ajax event="rowSelect" global="true" listener="#{busquedaBean1.selectedFuentes}" />
<p:ajax event="rowUnselect" global="true" listener="#{busquedaBean1.selectedFuentes}" />
<p:ajax event="toggleSelect" global="true" update="datos" listener="#{busquedaBean1.seleccionarTodos}" />
<p:column headerText="Nombre" style="width:80%;" sortBy="#{f.nombre}">
<h:outputText value="#{f.nombre}" />
</p:column>
<p:column headerText="Fecha" style="width:108%;" sortBy="#{f.fecha}" >
<h:outputText value="#{f.fecha}" />
</p:column>
<p:column headerText="Bloqueo" width="65" sortBy="#{f.bloqueo}">
<h:outputLabel value="#{f.bloqueo}" rendered="#{empty f.fechaBloqueo}" style="padding: 0 20%;"/>
<p:commandButton value="#{f.bloqueo}" rendered="#{ not empty f.fechaBloqueo}" id="detBloqueo" update=":form:carDetail" oncomplete="PF('carDialog').show()" icon="ui-icon-search" title="Mostrar detalles" style="background: transparent; color:#4297d7;border: 0px;" styleClass="detalles">
<f:setPropertyActionListener value="#{f}" target="#{busquedaBean1.autor}" />
</p:commandButton>
</p:column>
<p:column width="16" >
<h:commandLink title="Descargar" target="_blank" actionListener="#{descargarFormaBean.descargar(f.forma,f.nombre)}">
<span class="ui-button-icon-left ui-icon ui-icon-arrowthickstop-1-s" style="text-align:center;"></span>
</h:commandLink>
</p:column>
<p:column headerText="Directorio" width="190" sortBy="#{f.directorio}">
<p:commandButton value="#{f.dir}" id="detDirectorio" update=":form:dirDetail" oncomplete="PF('dirDialog').show()" title="Mostrar detalles" style="background: transparent; color:black;border: 0px;" styleClass="detalles">
<f:setPropertyActionListener value="#{f}" target="#{busquedaBean1.autor}" />
</p:commandButton>
</p:column>
<p:column id="SelectFuentes" style="width:16%;text-align:center" selectionMode="multiple" exportable="true" >
</p:column>
</p:dataTable>