package org.apache.wicket;
Abstract base class for pages. As a MarkupContainer subclass, a Page can contain a component
hierarchy and markup in some markup language such as HTML. Users of the framework should not
attempt to subclass Page directly. Instead they should subclass a subclass of Page that is
appropriate to the markup type they are using, such as WebPage (for HTML markup).
- Construction - When a page is constructed, it is automatically added to the current
PageMap in the Session. When a Page is added to the Session's PageMap, the PageMap assigns the
Page an id. A PageMap is roughly equivalent to a browser window and encapsulates a set of pages
accessible through that window. When a popup window is created, a new PageMap is created for the
popup.
- Identity - The Session that a Page is contained in can be retrieved by calling
Page.getSession(). Page identifiers start at 0 for each PageMap in the Session and increment as
new pages are added to the map. The PageMap-(and Session)-unique identifier assigned to a given
Page can be retrieved by calling getId(). So, the first Page added to a new user Session will
always be named "0".
- LifeCycle - Subclasses of Page which are interested in lifecycle events can override
onBeginRequest, onEndRequest() and onModelChanged(). The onBeginRequest() method is inherited
from Component. A call to onBeginRequest() is made for every Component on a Page before page
rendering begins. At the end of a request (when rendering has completed) to a Page, the
onEndRequest() method is called for every Component on the Page.
- Nested Component Hierarchy - The Page class is a subclass of MarkupContainer. All
MarkupContainers can have "associated markup", which resides alongside the Java code by default.
All MarkupContainers are also Component containers. Through nesting, of containers, a Page can
contain any arbitrary tree of Components. For more details on MarkupContainers, see
MarkupContainer.
- Bookmarkable Pages - Pages can be constructed with any constructor when they are being
used in a Wicket session, but if you wish to link to a Page using a URL that is "bookmarkable"
(which implies that the URL will not have any session information encoded in it, and that you can
call this page directly without having a session first directly from your browser), you need to
implement your Page with a no-arg constructor or with a constructor that accepts a PageParameters
argument (which wraps any query string parameters for a request). In case the page has both
constructors, the constructor with PageParameters will be used.
- Models - Pages, like other Components, can have models (see
org.apache.wicket.model.IModel). A Page
can be assigned a model by passing one to the Page's constructor, by overriding initModel() or
with an explicit invocation of setModel(). If the model is a
org.apache.wicket.model.CompoundPropertyModel, Components on the Page can use the Page's
model implicitly via container inheritance. If a Component is not assigned a model, the
initModel() override in Component will cause that Component to use the nearest CompoundModel in
the parent chain, in this case, the Page's model. For basic CompoundModels, the name of the
Component determines which property of the implicit page model the component is bound to. If more
control is desired over the binding of Components to the page model (for example, if you want to
specify some property expression other than the component's name for retrieving the model
object), BoundCompoundPropertyModel can be used.
- Back Button - Pages can support the back button by enabling versioning with a call to
setVersioned(boolean). If a Page is versioned and changes occur to it which need to be tracked, a
version manager will be installed using the
org.apache.wicket.session.ISessionStore's factory method
newVersionManager().
- Security - See
org.apache.wicket.authorization.IAuthorizationStrategy, org.apache.wicket.authorization.strategies.page.SimplePageAuthorizationStrategy
You can set implementation of the interface in the
Page.serializer then that
implementation will handle the serialization of this page. The serializePage method is called
from the writeObject method then the implementation override the default serialization.
Called when page is being deserialized
Returns object to be serialized instead of given page (called from writeReplace).
- Parameters:
serializedPage- Returns:
- object to be serialized instead of page (or the page instance itself)
This is a thread local that is used for serializing page references in this page.It stores a
Page.IPageSerializer which can be set by the outside world to do the serialization of this
page.
True if a new version was created for this request.
True if the page should try to be stateless
True if component changes are being tracked.
Used to create page-unique numbers
Numeric version of this page's id
The PageMap within the session that this page is stored in
Name of PageMap that this page is stored in
Set of components that rendered if component use checking is enabled
Boolean if the page is stateless, so it doesn't have to be in the page map, will be set in
urlFor
Version manager for this page
The page parameters object hat constructed this page
Constructor.
- Parameters:
pageMap
The page map to put this page in
The
PageParameters parameter will be stored in this page and then those parameters
will be used to create stateless links to this bookmarkable page.
- Parameters:
parameters
externally passed parameters- See also:
PageParameters
The
PageParameters parameter will be stored in this page and then those parameters
will be used to create stateless links to this bookmarkable page.
- Parameters:
pageMap
the page map to put this page inparameters
externally passed parameters- See also:
PageParameters
The
PageParameters object that was used to construct this page. This will be used in
creating stateless/bookmarkable links to this page
Called just before a component's listener method (the provided method argument) is called.
This method may be used to set up dependencies, enforce authorization, etc. NOTE: if this
method fails, the method will not be executed. Method
afterCallComponent(org.apache.wicket.Component,org.apache.wicket.RequestListenerInterface) will always be
called.
- Parameters:
component
the component that is to be calledlistener
the listener of that component that is to be called
Adds a component to the set of rendered components.
- Parameters:
component
The component that was rendered
" has the same wicket:id as another component already added at the same level");
Detaches any attached models referenced by this page.
Mark this page as dirty in the session
public final void dirty()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
This method is called when a component was rendered standalone. If it is a
MarkupContainer
then the rendering for that container is checked.
Expire the oldest version of this page
- Returns:
- The current ajax version number of this page.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
Get a page unique number, which will be increased with each call.
- Returns:
- A page unique number
- Returns:
- The current version number of this page. If the page has been changed once, the
return value will be 1. If the page has not yet been revised, the version returned
will be 0, indicating that the page is still in its original state.
- Returns:
- Returns the PageMap that this Page is stored in.
- Returns:
- Get a page map entry for this page. By default, this is the page itself. But if you
know of some way to compress the state for the page, you can return a custom
implementation that produces the page on-the-fly.
- Returns:
- String The PageMap name
- Returns:
- Size of this page in bytes
Returns whether the page should try to be stateless. To be stateless, getStatelessHint() of
every component on page (and it's behavior) must return true and the page must be
bookmarkable.
Override this method to implement a custom way of producing a version of a Page when it
cannot be found in the Session.
- Parameters:
versionNumber
The version desired- Returns:
- A Page object with the component/model hierarchy that was attached to this page at
the time represented by the requested version.
log.info("No version manager available to retrieve requested versionNumber " + page.versionManager = null;
- Returns:
- Number of versions of this page
- Returns:
- This page's component hierarchy as a string
Call this method when the current (ajax) request shouldn't merge the changes that are
happening to the page with the previous version.
This is for example needed when you want to redirect to this page in an ajax request and then
you do want to version normally..
This method doesn't do anything if the getRequest().mergeVersion doesn't return true.
Bookmarkable page can be instantiated using a bookmarkable URL.
- Returns:
- Returns true if the page is bookmarkable.
if (bookmarkable == null)
if (bookmarkable == null)
Override this method and return true if your page is used to display Wicket errors. This can
help the framework prevent infinite failure loops.
- Returns:
- True if this page is intended to display an error to the end user.
Gets whether the page is stateless. Components on stateless page must not render any
statefull urls, and components on statefull page must not render any stateless urls.
Statefull urls are urls, which refer to a certain (current) page instance.
- Returns:
- Whether this page is stateless
log.warn("Page '" + this + "' is not stateless because it is not bookmarkable, " + "but the stateless hint is set to true!");
returnArray[0] = component;
else if (returnValue instanceof Boolean)
Convenience method. Search for children of type fromClass and invoke their respective
removePersistedFormData() methods.
final boolean disablePersistence)
" is not a subclass of Form");
if (component instanceof Form)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
log.debug("Page not allowed to render: " + this); This returns a page instance that is rollbacked the number of versions that is specified
compared to the current page.
This is a rollback including ajax versions.
- Parameters:
numberOfVersions
to rollback- Returns:
- rollbacked page instance
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
Set the id for this Page. This method is called by PageMap when a Page is added because the
id, which is assigned by PageMap, is not known until this time.
Sets whether the page should try to be stateless. To be stateless, getStatelessHint() of
every component on page (and it's behavior) must return true and the page must be
bookmarkable.
- Parameters:
value
whether the page should try to be stateless
"Can't set stateless hint to true on a page when the page is not bookmarkable, page: " +
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
This method is called when a component will be rendered standalone.
Get the string representation of this container.
- Returns:
- String representation of this container
Throw an exception if not all components rendered.
- Parameters:
renderedContainer
The page itself if it was a full page render or the container that was rendered
standalone
unrenderedComponents.add(component);
if (unrenderedComponents.size() > 0)
boolean isTransparentMarkupContainer = sibling instanceof MarkupContainer &&
if (isTransparentMarkupContainer || isComponentResolver)
"Component {} wasn't rendered but most likely it has a transparent parent: {}", if (unrenderedComponents.size() > 0)
"The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered).\n\n" +
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.
Initializes Page by adding it to the Session and initializing it.
private final void init()
Initializes Page by adding it to the Session and initializing it.
- Parameters:
pageMap
The page map to put this page in.
For the given component, whether we may record changes.
- Parameters:
component
The component which is affectedparent- Returns:
- True if the change is okay to report
This method will be called for all components that are changed on the page So also auto
components or components that are not versioned.
If the parent is given that it was a remove or add from that parent of the given component.
else it was just a internal property change of that component.
- Parameters:
componentparent
Set-up response with appropriate content type, locale and encoding. The locale is set equal
to the session's locale. The content type header contains information about the markup type
(@see #getMarkupType()) and the encoding. The response (and request) encoding is determined
by an application setting (@see ApplicationSettings#getResponseRequestEncoding()). In
addition, if the page's markup contains a xml declaration like <?xml ... ?> an xml
declaration with proper encoding information is written to the output as well, provided it is
not disabled by an application setting (@see
ApplicationSettings#getStripXmlDeclarationFromOutput()).
Note: Prior to Wicket 1.1 the output encoding was determined by the page's markup encoding.
Because this caused uncertainties about the /request/ encoding, it has been changed in favor
of the new, much safer, approach. Please see the Wiki for more details.
response.write("<?xml version="); response.write(quoteChar);
response.write(quoteChar);
response.write(" encoding="); response.write(quoteChar);
response.write(encoding);
response.write(quoteChar);
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.
- Deprecated:
- TODO Remove in 1.4
- Returns:
- Factory method that creates a version manager for this Page
Renders this container to the given response object.
A component was added.
- Parameters:
component
The component that was added
A component's model changed.
- Parameters:
component
The component whose model is about to change
A component was removed.
- Parameters:
component
The component that was removed
Sets values for form components based on cookie values in the request.
- Parameters:
pageMap
Sets this page into the page map with the given name. If the page map does not yet
exist, it is automatically created.
Called when the page is retrieved from Session.
"Page does not support markup. This error can happen if you have extended Page directly, instead extend WebPage");