ding4
(ding pierre)
1
I have a table which uses BeanItemContainer to set the datasource, then when i want to add the footer, it doesn’t work.
In view, initialize the table container:
informationTableContainer = new BeanItemContainer<>(Info.class);
informationTable.setContainerDataSource(informationTableContainer);
Then, add the information and add the footer:
view.getInformationTable().setFooterVisible(true);
view.getInformationTable().setColumnFooter(view.NAME, view.TOTAL_ROW);
view.getInformationTable().setColumnFooter(view.NUMBER, String.valueOf(total));
view.getInformationTable().setColumnFooter(view.TOTAL, String.valueOf(total2));
view.getInformationTable().setPageLength(view.getInformationTable().size());
The content is correct, but the footer is not shown in the table.
Can you tell me why? Thank you.
Kevin125
(Kevin Hackin)
2
Hi,
Your code isn’t complete. So, it’s complicated to help you.
Here is an functional example (tested with Vaadin 7.4.7) :
Person class
public class Person {
private String name;
private String firstname;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
}
Testvaadin7UI class
public class Testvaadin7UI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = Testvaadin7UI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
BeanItemContainer<Person> container = new BeanItemContainer<Person>(Person.class);
Table t = new Table();
setContent(t);
Person p = new Person();
p.setName("dupond");
p.setFirstname("fany");
Person p2 = new Person();
p2.setName("durant");
p2.setFirstname("jacques");
container.addItem(p2);
container.addItem(p);
t.setFooterVisible(true);
t.setColumnFooter("name", "lastname");
t.setColumnFooter("firstname", String.valueOf(container.size()));
t.setContainerDataSource(container);
}
}