hello,

despite searching around I haven't found a good working example/explanation
of how to create a page where a form is repeated for each element in a
collection. (I found some info on using repeaters inside forms, but that is
a reverse situation).

Earlier in this thread there's the advice to use RefreshingView instead of
ListView. Is this good advice? What is the difference between them in this
scenario where forms should be repeated?

I tried doing it as below, but it causes a runtime exception. Can anyone
point out what I'm doing wrong and how it should be done?

The exception I'm getting is

Last cause: Unable to find component with id 'aForm' in [ListItem [Component
id = 0]]
        Expected: 'a-list:0.aForm'.
        Found with similar names: 'a-list:aForm'

The code is

        <div wicket:id="a-list">
            <form wicket:id="aForm">
                <input wicket:id="myproperty" type="text"/>
                <div>
                    <input wicket:id="save" type="submit" value="Save"/>
                    <input wicket:id="remove" type="submit" value="Remove"/>
                </div>
            </form>
        </div>

    private ListView aList = new ListView("a-list", aDAO.retrieveAll()) {
            @Override
            protected void populateItem(ListItem item) {
                final A a = (A) item.getModelObject();
                add(new AForm("aForm",
                        new CompoundPropertyModel(new
LoadableDetachableModel() {
                            @Override
                            protected Object load() {
                                return a;
                            }
                        })
                ));
            }};
 private class AForm extends Form {
        public AForm(String id, IModel m) {
            super(id, m);
            TextField myProperty= new TextField("myproperty");
            add(myProperty);
            add(new Button("save") {
                public void onSubmit() {
                    A selected = (A) getForm().getModelObject();
                    ADAO.save(selected);
                    setResponsePage(APage.class);
                }
            });
            add(
                    new Button("remove") {
                        @Override
                        public void onSubmit() {
                            A selected = (A) getForm().getModelObject();
                            ADAO.delete(selected);
                            setResponsePage(APage.class);
                        }
                    });
        }
    }

thanks in advance for your reply,
kind regards
Heikki Doeleman

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Repeating-form-on-a-page-tp2002098p3703919.html
Sent from the Users forum mailing list archive at Nabble.com.

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

Reply via email to