Vaadin table hide columns and container customization

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-03-18T17:36:10Z Indexed on 2010/03/19 6:21 UTC
Read the original article Hit count: 970

Filed under:
|
|

Hello

I am testing a project, using Vaadin and Hibernate. I am trying to use the HbnContainer class to show data into table. The problem is that I do not want to show all the properties of the two classes in the table.

For example:

@Entity
@Table(name="users")
class User {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String name;

@ManyToOne(cascade=CascadeType.PERSIST)
private UserRole role;

//getters and setters
}

and a second class:

@Entity
@Table(name="user_roles")
class UserRole {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String name;

//getters and setters
}

Next, I retrieve my data using the HbnContainer, and connect it to the table:

HbnContainer container = new HbnContainer(User.class, app);
table.setContainerDataSource(container);

The Table will only display the columns from User, and for the "role" it will put the role id instead. How can I hide that column, and replace it with the UserRole.name ?

I managed to use a ColumnGenerator() to get the string value in the table, for the UserRole - but I couldn't remove the previous column, with the numerical value.

What am I missing? Or, what is the best way to "customize" your data, before displaying a table (if i want to show data in a table from more than one object type.. what do I do?)

If I can't find a simple solution soon, I think I will just build the tables "by hand"..

So, any advice on this matter?

Thank you,
Alex

© Stack Overflow or respective owner

Related posts about vaadin

Related posts about table