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.
How do I get wrappedItem within the grid commitHandler?
HI I have a GeneratedPropertyContainer that wrapped the productContainer.
When I use editor of the Grid, when the field is commit , I need to get the Item from the productContainer rather than
GeneratedPropertyContainer. I tried to get GeneratedPropertyContainer.GeneratedPropertyItem within the class but it has protected constractor therefore I cannot create such a reference and use getWrappedItem().
Can anyone give me some suggestion that how do I get the Item fromt the orignal productContainer?
Thanks
productContainer = new BeanItemContainer<OrderProduct>(OrderProduct.class);
gpc = new GeneratedPropertyContainer(productContainer);
gpc.addGeneratedProperty("Total Price",new PropertyValueGenerator<Double>(){
@Override
public Double getValue(Item item, Object itemId, Object propertyId) {
// TODO Auto-generated method stub
Double price=(Double) item.getItemProperty("productPrice").getValue();
Double quantity=(Double)item.getItemProperty("productQuantity").getValue();
return price*quantity;
}
@Override
public Class<Double> getType() {
// TODO Auto-generated method stub
return Double.class;
}
});
orderGrid.setContainerDataSource(gpc);
orderGrid.setColumns("productName","productPrice","productQuantity","Total Price");
//Set Column Caption
orderGrid.getColumn("productName").setHeaderCaption(ConstantString.PRODUCT);
orderGrid.getColumn("productPrice").setHeaderCaption(ConstantString.PRICE);
orderGrid.getColumn("productQuantity").setHeaderCaption(ConstantString.QUANTITY);
// orderGrid.getColumn("totalPrice").setHeaderCaption(ConstantString.TOTALPRICE);
orderGrid.getColumn("Total Price").setHeaderCaption(ConstantString.TOTALPRICE);
//Set Footer of and display the Total Amount
orderGrid.setFooterVisible(true);
footerRow=orderGrid.prependFooterRow();
footerRow.getCell("productQuantity").setText(ConstantString.TOTALAMOUT);
orderGrid.setEditorEnabled(true);
orderGrid.getColumn("Total Price").setEditable(false);
orderGrid.setSelectionMode(SelectionMode.SINGLE);
orderGrid.getEditorFieldGroup().addCommitHandler(new CommitHandler(){
@Override
public void preCommit(CommitEvent commitEvent)
throws CommitException {
Item item = commitEvent.getFieldBinder().getItemDataSource();
}
@Override
public void postCommit(CommitEvent commitEvent)
throws CommitException {
}
});
I just browsed the changelog for 7.6.8, it seems this is fixed: https://dev.vaadin.com/ticket/20032
Tom Rauchenwald: I just browsed the changelog for 7.6.8, it seems this is fixed: https://dev.vaadin.com/ticket/20032
Thank you Tom, I will update to 7.6.8.
Best Regards,
James