You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Luther Baker <lu...@gmail.com> on 2009/04/01 21:03:23 UTC

DropDown Models

This select impl works just fine ... creating a project that must include a
Category from a drop down:

        public AddProjectForm(final String id)
        {
            super(id);

            this.project = new Project();
*            this.setModel(new CompoundPropertyModel(this.project));*

            // category
*            IModel categoryModel = new PropertyModel(this.project,
"category");*
            IModel detachableModel = new LoadableDetachableModel()
            {
                private static final long serialVersionUID =
-7673902927079196813L;

                @Override
                protected Object load()
                {
                    List<Category> categories =
ServiceLocator.getPersistenceService().findAll(Category.class);
                    return categories;
                }
            };
            ChoiceRenderer cr = new ChoiceRenderer("name", "id");
            DropDownChoice ddc = new DropDownChoice("category", *
categoryModel*, detachableModel, cr);
            ddc.setRequired(true);
            this.add(ddc);


I see that I set a model for the form -- and then I set another model
(albeit the same one) for the Drop Down.

In another case, I have a simple page that tries to DELETE a CATEGORY.

    private static class DelCategoryForm extends Form
    {
        private Category category;

        public DelCategoryForm(final String id)
        {
            super(id);

            this.category = new Category();
*            this.setModel(new Model(this.category));*

            // category
*            IModel categoryModel = new Model(this.category);*
            IModel detachableModel = new LoadableDetachableModel()
            {
                private static final long serialVersionUID =
-6814520399090264461L;

                @Override
                protected Object load()
                {
                    List<Category> categories =
ServiceLocator.getPersistenceService().findAll(Category.class);
                    return categories;
                }
            };
            ChoiceRenderer cr = new ChoiceRenderer("name", "id");
            DropDownChoice ddc = new DropDownChoice("categories", *
categoryModel*, detachableModel, cr);
            ddc.setRequired(true);
            this.add(ddc);

In this case, I don't think I need the CompoundPropertyModel or
PropertyModel since, the contents of the DROP DOWN indeed are everything I
need. So I changed the both to simply Model.

Unfortunately, values are always 'null' in the onSubmit handler of the
delete implementation. Any quick thoughts on what I'm doing incorrectly
here? Basically, I'm trying to populate the Category object with the select.
It works for the 1st example - but not in the second. In the first, it is a
property of a containing object - in the 2nd, it is the loan object.

Thanks,

-Luther

Re: DropDown Models

Posted by "luther.baker" <lu...@gmail.com>.
Ah ... found the issue.

-Luther


-- 
View this message in context: http://www.nabble.com/DropDown-Models-tp22833450p22855258.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org