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 {
}
});