use of io.github.zutherb.appstash.shop.ui.event.cart.RemoveFromCartEvent in project the-app by devops-dojo.
the class CartPanel method cartView.
private Component cartView() {
cartView = new ListView<CartItemInfo>("cart", cartListModel()) {
@Override
protected void populateItem(ListItem<CartItemInfo> item) {
WebMarkupContainer cartItem = new WebMarkupContainer("item");
cartItem.add(new Label("name", new PropertyModel<String>(item.getModel(), "product.name")));
cartItem.add(new IndicatingAjaxLink<Void>("delete") {
@Override
public void onClick(AjaxRequestTarget target) {
IModel<CartItemInfo> model = item.getModel();
send(CartPanel.this, Broadcast.BREADTH, new RemoveFromCartEvent(model.getObject(), target));
}
});
cartItem.add(new Label("price", new PriceModel(new PropertyModel<>(item.getModel(), "totalSum"))));
item.add(cartItem);
}
};
cartView.setReuseItems(false);
cartView.setOutputMarkupId(true);
return cartView;
}
Aggregations