How to show a specific property value of an item in a table..?

Hi all!

Ok i have a something like this:


class CategoryUser{... String name;}
class User{ ... CategoryUser category;}
class UserBeanContainer extends BeanItemContainer<User>{...}

....
User user = new User();
BeanItem<User> item = new BeanItem<User>(user);
UserBeanContainer cont = new UserBeanContainer();
cont.addItem(item);
Table table = new Table("Table",cont);
table.setVisibleColumns(new String[] { "id","name","category"});
table.setColumnHeaders(new String[] { "ID Numer", "Name", "Emplooyers","Type of Employee" }); 

so I need to show in the column of property “category”(in the table ofcourse) the "name"of that category (attribute of CategoryUser) instead the object itself.
what method must use?

greetings from Venezuela. :wink:

You need to add a nested container property to your container.

Something like this:


class CategoryUser{... String categoryName;}
class User{ ... String userName, CategoryUser categoryUser;}
class UserBeanContainer extends BeanItemContainer<User>{...}

....
User user = new User();
BeanItem<User> item = new BeanItem<User>(user);
UserBeanContainer cont = new UserBeanContainer();

cont.addNestedContainerProperty("categoryUser.categoryName");

cont.addItem(item);
Table table = new Table("Table",cont);

table.setVisibleColumns(new String[] { "id","userName","categoryUser.categoryName"}); //

table.setColumnHeaders(new String[] { "ID Numer", "User name","Type of Employee" });

I renamed some of your properties just to reduce confusion.

Kurt

thanks a lot Kurt.