📜 ⬆️ ⬇️

Stateless and Statefull pages in Wicket 1.4

To begin with, let's clarify what is at stake. Wicket stores the last page viewed in the session, but if the page is very large, sometimes this can be a problem. In order to avoid these problems, you can try to make a Stateless page (that is, a stateless one).
So, a stateless page is a stateless page, a statefull page is a state page.

Stateless pages do not store any state because there is no need to save them from request to request.
Such pages are not saved neither in the session nor in the history of visited pages stored on disk, such pages are not assigned a version, as it happens with statefull pages. With each request to such a page, its copy is created anew.

In order for a page to become stateless, two conditions must be met:

When these conditions are met, this page automatically becomes stateless. But if the page uses at least one component that is not stateless, then the whole page becomes a statefull, and completely grayed out and saved in the session, and further in the history on disk.

Let us consider these two conditions in more detail:
')
A bookmarkable page means that you can independently assign a URL to this page, and this URL does not contain any information related to the session (for example, the page version), and
it can be opened directly by typing the address in the browser, even if the session has not yet started.
In order for a page to be Bookmarkable, it must have a constructor that does not accept parameters or a constructor that accepts a single parameter of the PageParameter class.
If a page is created using a constructor that does not meet these conditions, the page will not be Bookmarkable.
If the page is not Bookmarkable, then it can be accessed only by creating it from another page.

The stateless or statefull component is defined using the getStatelessHint () method, which returns true if the stateless component is false and false if not.

The following components are stateless:


The following components are statefull:


Important: Link and Form are statefull. StatelessLink and StatelessForm are designed to use these components in stateless pages.

Sources:

cwiki.apache.org/WICKET/stateless-pages.html
cwiki.apache.org/WICKET/pages.html
cwiki.apache.org/WICKET/bookmarkable-pages-and-links.html
wicket.apache.org/apidocs/1.4
www.wicket-library.com/wicket-examples/compref

Source: https://habr.com/ru/post/143346/


All Articles