Binding BeanItemContainer within is array to the table

Hello friends,

I have BeanItemContainer which I would like to bind as a data source in my table.
BeanItemContainer has inside bean within is an array.
How could I do this ?

Below is my bean (POJO) within is nested the array:

[code]
package …

import java.io.Serializable;

public class EmployeesListPOJO implements Serializable

{

private EmployeesArray[] employeesArray;

public EmployeesArray[] getEmployeesArray()

{

    return employeesArray;

}

public void setEmployeesArray (EmployeesArray[] employeesArray)

{

    this.employeesArray = employeesArray;

}

public EmployeesListPOJO(){

}

}
[/code]And here is the nested array:

[code]
package …

public class EmployeesArray

{

private String lastname;

private String firstname;

public String getLastname ()

{

    return lastname;

}

public void setLastname (String lastname)

{

    this.lastname = lastname;

}

public String getFirstname ()

{

    return firstname;

}

public void setFirstname (String firstname)

{

    this.firstname = firstname;

}

@Override

public String toString()

{

    return "ClassPojo [lastname = "+lastname+", firstname = "+firstname+"]

";

}

public EmployeesArray(){

}

}
[/code]And here’s my attempt to bind it to the table:

BeanItemContainer<EmployeesListPOJO> container = new BeanItemContainer<EmployeesListPOJO>(EmployeesListPOJO.class);

Table table = new Table();

table.setContainerDataSource(container);

table.setVisibleColumns(new String[] {"employeesArray"});

table.setColumnHeader("employeesArray", "First name", "Last name");

I would like to have two column headers in my table: “First name” and “Last name”
which are associated to fields “firstname” and “lastname” in the array.

Thanks for the help !
Kindest greetings, Tom.

I assume you want to list EmployeesArray objects as rows into your Table? That would be somehting like this:

BeanItemContainer<EmployeesArray> container = new BeanItemContainer<EmployeesArray>(EmployeesArray.class);

for(EmployeesArray o : employeesListPOJO.getEmployeesArray()) {
    container.addItem(o);
}

Table table = new Table();
table.setContainerDataSource(container);
table.setVisibleColumns("firstname","lastname");
table.setColumnHeader("First name", "Last name");

Hi Tomasz, did you figure out this? I’m facing the same issue. But what about if you have your POJO with some atribute (creationDate for example) and want to show in table your pojo attribut and nested attribute? creationDate, firstName and Lastname for example.

Regards

Thanks