I have a problem with the DropDownChoice. More specifically, I have a
Product class which is like:

public class Product implements Serializable {

    private static final long serialVersionUID = 1L;

    private Manufacturer manufacturer;
    //other states

    //getters and setters

}

I have a form which allows to edit a product, which allows to change the
manufacturer object with a DropDownChoice. However, an Xbox product for
instance, it should display its Microsoft manufacturer object as selected
but it selects 'Choose One' instead. Also, the setRequired for the
DropDownChoice does not work as it allows users to select 'Choose One'. I
notice it works with primitive types but not with my compositional objects.

Here is my EditProductPage:

package net.sourceforge.springcart.wicket.pages.admin;

public class EditProductPage extends AdminPage {

    private static final long serialVersionUID = 1L;

    @SpringBean(name = "adminService")
    private AdminService adminService;

    public EditProductPage() {
        this(new Product());
    }

    public EditProductPage(Product product) {
        MenuBorder border = new MenuBorder("libBorder");
        border.add(new EditProductForm("productForm", product));
        add(border);
    }

    private final class EditProductForm extends Form {

        public EditProductForm(String id, Product product) {
            super(id, new CompoundPropertyModel(product));
            add(new RequiredTextField("name"));
            add(new RequiredTextArea("description"));
            add(new RequiredTextField("sellValue", BigDecimal.class));
            add(new RequiredTextField("units", Long.class));
            add(new CheckBox("onSell").setRequired(true));
            add(new DropDownChoice("category", catalogService.getCategories
())
                    .setRequired(true));
            add(new DropDownChoice("manufacturer", catalogService
                    .getManufacturers()).setRequired(true));
        }

        @Override
        protected void onSubmit() {
            Product product = (Product) getModelObject();
            product.setEntryDate(new Timestamp(System.currentTimeMillis()));
            adminService.updateProduct(product);
            setResponsePage(ViewProductsPage.class);
        }

    }

}

Any advice please?

Cheers,
James.

Reply via email to