Skip to content

dataTable: backing bean doesn't recive ajax events #50

@wgualla

Description

@wgualla

Hi, I'd made this simple page (and it's simple back bean). The back bean methods (onDataSelect()/onSelectChanged()) are never called. Can anyone tell me what I'm doing wrong?

Thank you all.

My xhtml
`
<h:body>
<h:form id="form-id">

                <b:dataTable 
                  value="#{pruebaDataTable.datos}"
                  var="doc"
                  id="document-table-id"
                  page-length="5"
                  striped="true"
                  save-state="true"
                  searching="false"
                  border="false"
                  row-highlight="true"
                  lang="ES-es"
                  select="true" 
                  ajax="true"
                  onselect="ajax:PruebaDataTable.onDataSelect()"
                  paginated="false"
                  >

                  <b:dataTableColumn  
                      id="document-table-type-id"
                      label="Type"
                    orderable="false"
                    data-type="text"
                    >

                    <h:outputText id="document-table-nom-id" value="#{doc.id}" />
                  </b:dataTableColumn>
                  <b:dataTableColumn 
                        id="document-table-num-id"
                        label="Number"
                        orderable="false"
                                     >
                    <h:outputText id="document-table-numero-id" value="#{doc.codigo}" />
                  </b:dataTableColumn>

                  <b:dataTableColumn 
                        id="document-table-chk-id"
                        label="select"
                        orderable="false"
                                     >
                      <b:selectBooleanCheckbox 
                          id="document-table-select-id" 
                          value="#{doc.selected}" 
                          ajax="true" process="@this" update="@this" 
                          onchange="ajax:PruebaDataTable.onSelectChanged()" 
                          />
                  </b:dataTableColumn>

                </b:dataTable>

    </h:form>

</h:body>

`

My .java backbean.

`

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

/**
*

  • @author wgualla
    */
    @nAmed
    @SessionScoped
    public class PruebaDataTable implements Serializable {

    protected static List datos=new ArrayList<>();

    /**

    • @return the datos
      */
      public List getDatos() {
      return datos;
      }

    public void onDataSelect() {
    System.out.println("PruebaDataTable.onDataSelect, event recived!!!");
    }

    public void onSelectChanged(){
    System.out.println("PruebaDataTable.onSelectChanged, event recived!!!");
    }

    /**

    • @param aDatos the datos to set
      */
      public void setDatos(List aDatos) {
      datos = aDatos;
      }

    @PostConstruct
    public void init(){
    getDatos().add(new Datos(0,"000","desc 0"));
    getDatos().add(new Datos(1,"001","desc 1"));
    getDatos().add(new Datos(2,"002","desc 2"));
    getDatos().add(new Datos(3,"003","desc 3"));
    getDatos().add(new Datos(4,"004","desc 4"));
    }

    public static class Datos {

    protected int id;
    protected String codigo;
    protected String descripcion;
    protected boolean selected;
    
    public Datos(int id, String codigo, String descripcion){
        this.id=id;
        this.codigo=codigo;
        this.descripcion=descripcion;
    }
    /**
     * @return the id
     */
    public int getId() {
        return id;
    }
    
    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }
    
    /**
     * @return the codigo
     */
    public String getCodigo() {
        return codigo;
    }
    
    /**
     * @param codigo the codigo to set
     */
    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }
    
    /**
     * @return the descripcion
     */
    public String getDescripcion() {
        return descripcion;
    }
    
    /**
     * @param descripcion the descripcion to set
     */
    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }
    
    /**
     * @return the selected
     */
    public boolean isSelected() {
        return selected;
    }
    
    /**
     * @param selected the selected to set
     */
    public void setSelected(boolean selected) {
        this.selected = selected;
    }
    

    }
    }
    `
    my .pom

    4.0.0

    xxxx
    xxxxxxxx
    1.0
    war

    xxxxxxx

    ${project.build.directory}/endorsed UTF-8
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.2</version>
        <scope>provided</scope>
    </dependency>
    
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
        <version>2.5.2</version>
        <scope>provided</scope>
    </dependency>
    
    <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.2</version>
    </dependency>
    
    <dependency>
        <groupId>jod</groupId>
        <artifactId>jodconverter</artifactId>
        <version>2.2.2</version>
    </dependency>
    
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.4</version>
    </dependency>
    
    <dependency>
        <groupId>org.openoffice</groupId>
        <artifactId>juh</artifactId>
        <version>3.0.1</version>
    </dependency>
    
    <dependency>
        <groupId>org.openoffice</groupId>
        <artifactId>unoil</artifactId>
        <version>3.0.1</version>
    </dependency>
    
    <dependency>
        <groupId>jodconverter</groupId>
        <artifactId>xstream</artifactId>
        <version>1.3.1</version>
    </dependency>
    
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>1.5.6</version>
    </dependency>
    
    <dependency>
        <groupId>jodconverter</groupId>
        <artifactId>jodconverter-cli</artifactId>
        <version>2.2.2</version>
    </dependency>
    
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>EasyHC3Persistence</artifactId>
        <version>${project.version}</version>
    </dependency>
    
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    
    <dependency>
        <groupId>net.bootsfaces</groupId>
        <artifactId>bootsfaces</artifactId>
        <version>0.9.0</version>
        <scope>compile</scope>
    </dependency>
    
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.3</version>
        <scope>compile</scope>
    </dependency>
    
    <dependency>  
      <groupId>org.primefaces.themes</groupId>  
      <artifactId>all-themes</artifactId>  
      <version>1.0.10</version>  
    </dependency> 
    
    <dependency>
       <groupId>de.larmic.butterfaces</groupId>
       <artifactId>components</artifactId>
       <version>2.1.8</version>
    </dependency>
    
    prime-repo PrimeFaces Maven Repository http://repository.primefaces.org default org.apache.maven.plugins maven-compiler-plugin 3.1 1.7 1.7 ${endorsed.dir} org.apache.maven.plugins maven-war-plugin 2.3 false org.apache.maven.plugins maven-dependency-plugin 2.6 validate copy ${endorsed.dir} true javax javaee-endorsed-api 7.0 jar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions