On Thu, 2006-08-10 at 01:05 +0200, Johan Compagner 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.

setReuseItems does not make sense with pull models cause it stores the
items, and does not rebuild the list items. 

I'm gradually getting to a conclusion that ListView sucks, and should be
replaced with something more robust. A core component should not have
following problems:

- you have to remember to call setReuseItems if it is within a form
- you can't call setReuseItems if you use pull models
- it fails if some other process changes the database 

> 
> 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...

Manually removing the IFromValidators is not a good option (even if the
api would be opened). Why should we manually remove them while the "old"
components are automatically replaced by ListView?

Joni

> 
> 
> 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