Dificult updating a table with BeanItemContainer

Hi folks,

I have tried to update a table which is filled with a BeanItemContainer but unsuccessfully.

Well, he we go.

I have a table with seven columns, the last (ocStatistic) is type Integer, its value for the first act is 0 (zero). During a process each record is updated and the seven column, ocStatistic, receive its value. However, after the process the table looks like the attached image.

This is my code to assign the new value for ocStatistic:

Item tableItem = table.getItem(data); // data is a bean instance.

I have tried too:


In the second attempt, getDataContainer() is getter (of the attribute which represents) that returns the table DataSource.

Could you help me?

Hi. another doubt. If I scroll through the entire collection in a container, it is affects the table repainting?

I get the table.getContainerDataSource() and then, make a foreach using collection inside and update a bean property value.

Could this process affect the table repaint? The idea is to show the new value.

Remembering that my table container is a BeanItemContainer.

Another information about. If you see the table appearence after de process that change values of the last column, you can notice that just two rows has no problems. Notice that the value in the last column remains (In the first act the value was 0. Now continue being 0). For all other records the value has changed and the correlat line in the table didn’t appear.

Setting 0 for all records during the process makes the table presents data correctly.

My intention is update the data in the last column, not that remain equals.



I think i don’t quite understand your problem yet.

Is your problem that you’re trying to assign the value in the last column and it’s not working (always stays 0)?

Hi Marius, first off, I am grateful for your help. I spent hours trying to solve this issue. You are the first to try to help.

Well, let’s address my true issue. I have a table that receive some data from a query. I am using a BeanItemContainer to bind data which is a Collection, result of the query.

A first scenario, when get the data, the last column is assigned as 0 (zero) in all rows. This value is an arbitrary value retrieved from the database.

In a second moment, I implement a foreach using the Collection inside the BeanItemContainer intending to update the value in the last column and it works. However, my table does not displays data correctly after this process.

In my first post (on the top) you can notice an attached print of my table illustrating the problem. You will see that just two rows remains equals after the process, curiously, the ones that had not its values changed.

Take a closer look at enclosed prints. “First” shows the grid before process to change the last column value, “second” shows the grid after the process. Below, you can observe the rotine that change the last column value:

private void performSolrQuery() throws MalformedURLException, SolrServerException {
		Collection<Data> collection = getDataContainer().getItemIds();
		ModifiableSolrParams params = new ModifiableSolrParams();
		for (Data data : collection) {

			URL url = new URL(new URL(Utils.SOLR_SERVER), data.getNmIndex());
			HttpSolrServer solrServer = new HttpSolrServer(url.toString());

			params.set("q", data.getNmField() + ":[* TO *]
			params.set("start", "0");
			params.set("rows", "0");
			params.set(FacetParams.FACET, true);
			params.set(FacetParams.FACET_MISSING, true);
			QueryResponse response = solrServer.query(params);
			Long result = response.getResults().getNumFound();

In the code above, look at lines 4 and 23, where I get the collection from table (BeanItemContainer) and where I set the new value for the last column, performing a foreach to repeat the process for all rows.

Any doubt, feel free to ask.

The files, first and second.

Which vaadin version are you using?

Sry that i can’t pay more attention right now but i’m at work. i will have a closer look later.


Essentially, what you have show us appears to be fine. Here’s a complete (Vaadin 7) working example, demonstrating change the values of a tables columns in exactly the same way that doesn’t appear to be working for you. (i.e. by clicking Increase Age button, the code loops through all of the items on the table, and increments the age property by 10).

The container is a plain-old-bean container.

I suspect that the problem you have lies in the Container/Item/Bean area, not in the changing-the-value area.

HTH A Little,


public class ChangePropertyValue extends UI {
  protected void init(VaadinRequest request) {
    /* Lets create some data */
    Person[] people = new Person[]
        new Person("Fred Boggins", 20),
        new Person("Doris Day", 98),
        new Person("Freddy Flintoff", 38),
        new Person("Boris van Clinkenthorp", 52)

    /* Create the bean container for the table */
    BeanContainer<Person, Person> container = new BeanContainer<Person, Person>(Person.class);
    for (Person person : people) {
      container.addItem(person, person);

    /* Build the table */
    final Table table = new Table("People", container);
    table.setImmediate(true); // I always forget this : needed so that selection events occur immediately

    /* Create a button that modifies the age value via the item interface*/
    Button increaseAge = new Button("Increase Age", new Button.ClickListener() {
      public void buttonClick(Button.ClickEvent event) {
        Collection<?> ids = table.getItemIds();
        for (Object id : ids) {
          Item item = table.getItem(id);
          Property<Integer> property = (Property<Integer>) item.getItemProperty("age");
          property.setValue(property.getValue() + 10);

    /* Set up the window/ui with the table and form */
    HorizontalLayout mainLayout = new HorizontalLayout();

    setContent(mainLayout); // Different in Vaadin 6

   * The Person bean to be displayed
  public class Person {
    protected String name;
    protected int age;

    public Person() {

    public Person(String name, int age) {
      this.name = name;
      this.age = age;

    public int getAge() {
      return age;

    public void setAge(int age) {
      this.age = age;

    public String getName() {
      return name;

    public void setName(String name) {
      this.name = name;


I am using 7.0.6 version.

It sounds like a bug. I will try to change the type of the container and post here the result.

Just another day in paradise.

I have tried to implement the same code, with a slight change, usign BeanContainer instead BeanItemContainer, and the result was that…

a drum roll, please…

IT DOES NOT WORK TOO!! I faced the same problem.

Then, to me is change the value my big question. Somehow, when the value is changed the container does not find more that item and cannot display it.

As I said in early post, just in two rows, the last column keeps the initial value. Interesting observe, that these rows remains displayed correctly.


Stop everything…

It works!

The problem was the value.

Since my bean has no ID, then, wrong, I know, I implement the equals (in my bean) using all attributes. Accordingly my recen-last post, the container use the equals to localize the item inside.

Thinking a little about, I decided to change my equals and, then, voilá!!

I am grateful for your time, Charles Anthony and Marius Reinwald.

A nice weekend for all Vaadiners. :wink: