Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Conditional table converter (based on another field)
Hi guys,
i'm creating a new table for my project with this structure:
ID | ID_STATE | ID_USER | .....
So, my problem is this one: i'd like to convert the ID_STATE to a most presentable value, but to do that i need to access the corresponding ID_USER field (since i have a mapping in the db).
Can i do that with a converter? Basically i think i'll have to extrapolate the rowId to get to the other properties...
Or should i write an extended version of table? And how?
Thanks a lot!
Alberto
Not sure if this helps:
Table t = new Table(){
@Override
protected String formatPropertyValue(final Object rowId, final Object colId, final Property<?> property) {
String result = super.formatPropertyValue(rowId, colId, property);
if (colId.equals("ID_STATE")) {
result = //Maybe some enumerated state list
} else {
return "";
}
return result;
}
};
Thanks a lot! That actually (almost) did it.
I was able to cast rowId into my pojo type and extract the data from there.
In other words:
Table t = new Table(){
@Override
protected String formatPropertyValue(final Object rowId, final Object colId, final Property<?> property) {
String result = super.formatPropertyValue(rowId, colId, property);
switch(colId.toString()){
case "ID_STATE":
result = connect_to_db(((myobj)rowId).getId());
break;
......
return result;
}
};
Thanks a lot!