But we have now a nice option to reduce those callbacks:
/**
* Returns whether the component can be stateless. Being able to be
* stateless doesn't necessary mean, that the component should be stateless.
* Whether the component should be stateless depends on
*
* @return whether the component can be stateless
*/
protected boolean getStatelessHint()
{
return true;
}
Byt default it is true. But for all components that are implementing a listener do override
this method and return false.
We have a 2 StatelessComponents so developers will notice them better and the code makes it clear
that they are really meant to be stateless:
StatelessLink and StatelessForm
These extend Link and Form but then return true again for the hint.
When that hint returs true the component can return true on the isStateless() call (if also all behaviours are stateless)
if that is the case and the page is bookmarkable (default constructor or page param constructor)
then a special url is generated that is a bookmarkable part and the interface part in one go
so you have the bookmarkablePage=xxx and the interface=xxx in the url. (or a mount with that interface=xxx)
When a request comes in for such an url. It fist checks the interface stuff (is the page still there) and if it finds
the page it goes on as a normal Interface request. If it isn't it becomes bookmarkalble interface request.
This means that the page is created just as a normal bookmarkable request but not only for rendering but
first it calls the interface that was asked for.
If all components on the page are stateless (stateless hint returns true and no statefull behaviours) and the page
is not redirected to (this will make the page statefull) the page will be stateless and all urls will be bookmarkable
or a combination of bookmarkable and an interface request..
So you could build now a login screen (that is the first screen you see when you hit the side)
that will not make a session and can always be used by using a StatelessForm as the login form.
Or you could have a main page where you have a search box but for the rest it is only static data. Also then
a stateless form would be the best option.
One thing ofcourse to remember when using a StatelessLink, StatelessForm or your own component
that returns true for the getStatelessHint(). Is that you can't use model data that can change over the livetime
of a page.
The model data is always exactly that data that is there when the page is constructed! It doesn't have to be
the same data that was there the time the component did render. Because the page is or can be recreated.
so you have a 'clean' page again. The StatelessForm is a bit of an exception because the state of the form
is pushed from the client. for the large part through the form components. So getModelObject in a stateless
form on a submit will work just as fine. The only thing here is that if you have form components can't be altered
in the live time (over multiply request) of a page. For example setting an other validator or setting required
at some point other then page construction won't work. Because the page can be recreated when the form
is submitted so the formcomponents will then be in the initial state. But i guess this is not a problem
for many cases.
johan
P.S. Matej any comments?
On 9/22/06,
Eelco Hillenius <[EMAIL PROTECTED]> wrote:
Hi,
Can someone (Johan?) explain exactly how/ when pages are stateless
with Wicket 2.0 and what the corner cases are? I'm writing something
about it now, and even though I kind of reversed engineered it, It'd
like to hear from the people who built it.
Cheers,
Eelco
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net 's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-develop mailing list
Wicket-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-develop
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Wicket-develop mailing list Wicket-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-develop