Search in sources :

Example 1 with PriceModel

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;
}
Also used : CartItemInfo(io.github.zutherb.appstash.shop.service.cart.model.CartItemInfo) RemoveFromCartEvent(io.github.zutherb.appstash.shop.ui.event.cart.RemoveFromCartEvent) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IndicatingAjaxLink(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink) PriceModel(io.github.zutherb.appstash.shop.ui.model.PriceModel)

Example 2 with PriceModel

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();
        }
    };
}
Also used : ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) PriceModel(io.github.zutherb.appstash.shop.ui.model.PriceModel)

Aggregations

PriceModel (io.github.zutherb.appstash.shop.ui.model.PriceModel)2 Label (org.apache.wicket.markup.html.basic.Label)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 CartItemInfo (io.github.zutherb.appstash.shop.service.cart.model.CartItemInfo)1 RemoveFromCartEvent (io.github.zutherb.appstash.shop.ui.event.cart.RemoveFromCartEvent)1 List (java.util.List)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 IndicatingAjaxLink (org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1 ListView (org.apache.wicket.markup.html.list.ListView)1