use of io.github.zutherb.appstash.shop.ui.model.PriceModel 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;
}
use of io.github.zutherb.appstash.shop.ui.model.PriceModel in project the-app by devops-dojo.
the class OrderItemListPanel method orderItemList.
private Component orderItemList() {
return new ListView<OrderItemInfo>("orderItems", new PropertyModel<List<OrderItemInfo>>(getDefaultModel(), "orderItems")) {
private int orderItemCounter = 1;
@Override
protected void populateItem(ListItem<OrderItemInfo> orderItem) {
orderItem.add(new Label("orderItemCounter", Model.of(orderItemCounter++)));
orderItem.add(new Label("product", new PropertyModel<String>(orderItem.getModel(), "product.name")));
orderItem.add(new Label("description", new PropertyModel<String>(orderItem.getModel(), "product.description")));
orderItem.add(new Label("totalSum", new PriceModel(new PropertyModel<>(orderItem.getModel(), "totalSum"))));
}
@Override
protected void onDetach() {
orderItemCounter = 1;
super.onDetach();
}
};
}
Aggregations