and because the listview might remove items for you as well if they have been deleted from the database by someone else :)

-Igor


On 8/9/06, Johan Compagner <[EMAIL PROTECTED]> wrote:
This code is extremely ugly!

Everytime you render the page the form gets a new FormValidator because everytime the listview is populated..
Do setReuseItems(boolean reuseItems) to true on the ListView.

And if you remove them yourself you should be able to also delete the validator from the form
because that one is really not valid anymore...
but that is a problem because there is no remove(validator) method i think...



On 8/8/06, Joni Freeman <[EMAIL PROTECTED]> wrote:
Consider following form which uses ListView with pull model.

public MyForm extends Form {
    public MyForm(String id, IModel model) {
        super(id, model);
        add(new ListView("items") {
            public IModel getModel() {
                return new Model( dao.findAll());
            }

            protected void populateItem(final ListItem item) {
                FormComponent text1 = new TextField("t1");
                FormComponent text2 = new TextField("t2");
                item.add(text1);
                item.add(text2);
                MyForm.this.add(new MyFormValidator(text1, text2));
            }
        };
    }

    protected void onSubmit() {
        // hello world!
    }
}

Now, the first submit is ok, but if the validation fails during the
first submit and the user presses submit again, the whole form fails to
Caused by: java.lang.IllegalStateException : No Page found for component
[MarkupContainer [Component id = TextField.text, page = <No Page>, path
= 1:semester.length:start:TextField.text]]
  at wicket.Component.getPage(Component.java:1022)
  at wicket.Component.hasErrorMessage (Component.java:1226)
  at
wicket.markup.html.form.FormComponent.isValid(FormComponent.java:442)
...

Why? Because the Form instance contains FormValidators which reference
old instances of FormComponents. These old instances are not in a Form
after the first submit because the ListView uses pull model and
therefore can't call setReuseItems(true);

So, it seems that it is not possible to use pull model ListView in a
Form?

Joni


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to