Hi,

I have made a CheckGroup vith a ListView of Check's than works fine, except
that when it is submitted and I'm on the next page and want to go back
through a Wicket Button (not the browsers back button), all the checks are
empty even thouch the model behind still contains the selected obejcts. Here
is the example code of the first page:

public HomePage() {
        Order order = ((WicketSession) (Session.get())).getOrder();
        if (order.getDigitalPackets() == null)
            order.setDigitalPackets(new ArrayList<Product>());
        System.err.println("LIST1 = " + order.getDigitalPackets());
        Form form = new DigitalOrderForm("digitalOrderForm");
        form.setModel(new CompoundPropertyModel(order));
        add(form);
        List<Product> allProducts = new ArrayList<Product>();
        for (int i = 0; i < 10; i++) {
            Product p = new Product();
            p.setProductKey(i + "");
            p.setTotalPrice(new BigDecimal(100 + i));
            p.setProductName("Product" + i);
            allProducts.add(p);
        }
        CheckGroup group = new CheckGroup("digitalPackets");
        form.add(group);
        ListView products = new ListView("products", allProducts) {
            protected void populateItem(ListItem item) {
              item.add(new Check("check",
item.getModel()).setEscapeModelStrings(false));
              item.add(new Label("productName", new
PropertyModel(item.getModel(), "productName")));
              item.add(new Label("totalPrice", new
PropertyModel(item.getModel(), "totalPrice")));
            }
        };
        group.add(products.setReuseItems(true));
    }

    class DigitalOrderForm extends Form {
        DigitalOrderForm(String s) {
            super(s);
        }

        protected void onSubmit() {
            Order order = (Order) getModelObject();
            System.err.println("LIST2 = " +
order.getDigitalPackets());
            setResponsePage(PageTwo.class);
        }
    }

The second page is just a back button like this:

public PageTwo() {
        add(new Button("back") {
            public void onSubmit() {
                setResponsePage(HomePage.class);
            }
        });
    }

Anybody knows how to get the selected objects shown when you go back like
that ?

/Steen

Reply via email to