Gili wrote:

I also found the existing documentation confusing because it said they may have either a default constructor or a PageParameters one and I was left asking... "but why?! What's the difference between the two constructors? when is each called?" We should just simplify it into a single constructor.

NO! Like Johan said: it depends on the usecase. Both have meaning. Both have a right to exist. I am not a native English speaker, and I don't find it in any way confusing when the documentation states 'either this or that'. I find it pretty clear when one constructor has PageParameters and the other doesn't, that /the/ difference is, that one of the constructors actually wants page parameters, and the other doesn't or doesn't care. Usually I don't even put a PageParameters constructor in my pages, but I can definetely see valid usecases for them.

I think it is also clear that a page with either a parameterless constructor or a PageParameters constructor is bookmarkable. No specific state is necessary to create such a page. But being bookmarkable is not special. /NOT/ being bookmarkable is the special case: then you provide your own parameters to the constructor, which makes them stateful, and thus not bookmarkable. Very clear distinction in my opinion.

A page can even have both stateful and stateless constructors. Then the page is both bookmarkable and non-bookmarkable:

public class PersonPage extends WebPage {
   public PersonPage(final Person person) {
   }
   public PersonPage(final PageParameters parameters) {
   }
   public PersonPage() {
   }
}

One page, multiple constructors. Wicket can only cope with the default and PageParameters constructor, as those are only known to Wicket and are constructable from a HttpRequest (with or without parameters). The Person based constructor is specific for your application. So you can use it all over your application in Links, submits, etc. But you can't use a page constructed using the Person constructor in a bookmark as there is no way to construct the required person object.

And what happens if you only have a default constructor and the page needs to be constructed due to an incoming request? The page will be created, and the request parameters ignored. Just as with any other servlet/java solution not specifically checking whether a parameter is extraeneous.
See:
http://www.wicket-library.com/wicket-examples/helloworld?thisParameterDoesntExist=fooBar

Martijn


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September
19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop

Reply via email to