Areq
(Areq Koval)
1
Hi,
I created a lot of rows in table like this:
BeanItemContainer<A> elementsDataModel = BeanItemContainer<A>(A.class);
for (...)
elementsDataModel.add(new A (id, name, type));
How May I add relations into table after creating data model ?
for example:
I want to add relation (parent - child) beetween A{id : 4} and A{ id : 6}
myTable.setParent(?, ?)
thanks
Areq
wollekk
(Wolfgang Wachsmuth)
2
Hi Areq,
- You must call myTable.setContainerDataSource(elementsDataModel), this will wrap your BeanItemContainer into a ContainerHierarchicalWrapper.
- Becasue your BeanItemContainer uses the IdentityBeanIdResolver you can use your beans as identifier. So you can write
A parent = getParent();
A child = getChild();
myTable.setParent(parent, child);
Beware of correct hashCode() and equals() methods!
baptiste9
(baptiste prieur)
3
I try to use method setParent of TreeTable object.
I have an object of type X with two attributes filled like below :
X1 with id=1 and name=“x1”
X2 with id=1 and name=“x2”.
X1 and X2 has same id but different name.
The class of type X has a method equals and hashcode on attribute id and name.
The X1 and X2 object has different hashCode.
And I do :
treetable.addItem(X1);
treetable.addItem(X2);
treetable.setParent(1,0);
X2 has ItemId equals to 1 and X1 has itemId equals to 0. Thus, X1 is parent of X2.
But, on result, in my table, I have two distinct occurs. And X2 is not a child of X1.
Can you explain to me the problem ?
Thanks by advance for your explanation.