- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IMetadataContext<Serializable,
,Component> IQueueRegion
,IHeaderContributor
,IManageablePage
,IRequestableComponent
,IRequestablePage
,IHierarchical<Component>
,IClusterable
- Direct Known Subclasses:
WebPage
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).
Page has the following differences to Component
s main concepts:
- Identity - Page numerical identifiers start at 0 for each
Session
and increment for each new page. This numerical identifier is used as the component identifier accessible viagetId()
. - Construction - When a page is constructed, it is automatically registerd with the
application's
IPageManager
.
Pages can be constructed with any constructor like any other component, 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 aPageParameters
argument (which wraps any query string parameters for a request). In case the page has both constructors, the constructor with PageParameters will be used. - Versioning - Pages support the browser's back button when versioning is enabled via
Component.setVersioned(boolean)
. By default all pages are versioned if not configured differently inPageSettings.setVersionPagesByDefault(boolean)
- Author:
- Jonathan Locke, Chris Turner, Eelco Hillenius, Johan Compagner
- See Also:
-
Field Summary
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
Constructor Summary
ModifierConstructorDescriptionprotected
Page()
Constructor.protected
Constructor.protected
Page
(PageParameters parameters) ThePageParameters
parameter will be stored in this page and then those parameters will be used to create stateless links to this bookmarkable page. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
componentChanged
(Component component, MarkupContainer parent) This method will be called for all components that are changed on the page So also auto components or components that are not versioned.final void
componentRendered
(Component component) Adds a component to the set of rendered components.void
Detaches any attached models referenced by this page.final void
dirty()
void
dirty
(boolean isInitialization) Mark this page as modified in the session.final int
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.final String
getId()
Gets the id of this component.Get the type of associated markup for this component.int
ThePageParameters
object that was used to construct this page.Gets page instance's unique identifierint
Returns the number of times this page has been rendered.final long
final boolean
Returns whether the page should try to be stateless.final String
protected final void
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.boolean
Bookmarkable page can be instantiated using a bookmarkable URL.boolean
Override this method and return true if your page is used to display Wicket errors.final boolean
Gets whether the page is stateless.protected void
Called immediately after a component and all its children have been rendered, regardless of any exception.protected void
Called on all visible components before any component is rendered.protected void
Called on all components before any component is rendered.protected void
onDetach()
Called to allow a component to detach resources after use.protected void
This method is meant to be used as an alternative to initialize components.protected void
onRender()
Implementation that renders this component.void
Renders the pageboolean
setFreezePageId
(boolean freeze) Sets whether or not the page is allowed to change its page id.final void
setNumericId
(int id) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.final Page
setStatelessHint
(boolean value) Sets whether the page should try to be stateless.final void
setWasCreatedBookmarkable
(boolean wasCreatedBookmarkable) THIS METHOD IS NOT PART OF WICKET API.toString()
Get the string representation of this container.final boolean
Checks if this page was created using one of its bookmarkable constructorsfinal boolean
wasRendered
(Component component) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, visitChildren, visitChildren
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onComponentTag, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.wicket.page.IManageablePage
detach
Methods inherited from interface org.apache.wicket.IQueueRegion
dequeue, getRegionMarkup, newDequeueContext
Methods inherited from interface org.apache.wicket.request.component.IRequestableComponent
canCallListenerAfterExpiry, detach, get, getBehaviorById, getBehaviorId, getPage, getPageRelativePath
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Page
protected Page()Constructor. -
Page
Constructor.- Parameters:
model
- See Component- See Also:
-
Page
ThePageParameters
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:
-
-
Method Details
-
getPageParameters
ThePageParameters
object that was used to construct this page. This will be used in creating stateless/bookmarkable links to this page- Specified by:
getPageParameters
in interfaceIRequestablePage
- Returns:
PageParameters
The construction page parameter
-
componentRendered
Adds a component to the set of rendered components.- Parameters:
component
- The component that was rendered
-
detachModels
Detaches any attached models referenced by this page.- Overrides:
detachModels
in classComponent
-
onConfigure
Description copied from class:Component
Called on all components before any component is rendered. This method should be used to configure such things as visibility and enabled flags.Overrides must call
super.onConfigure()
, usually before any other codeNOTE: Component hierarchy should not be modified inside this method, instead it should be done in
Component.onBeforeRender()
NOTE: Why this method is preferrable to directly overriding
Component.isVisible()
andComponent.isEnabled()
? Because those methods are called multiple times even for processing of a single request. If they contain expensive logic they can slow down the response time of the entire page. Further, overriding those methods directly on form components may lead to inconsistent or unexpected state depending on when those methods are called in the form processing workflow. It is a better practice to push changes to state rather than pull.NOTE: If component's visibility or another property depends on another component you may call
other.configure()
followed byother.isVisible()
as mentioned inComponent.configure()
javadoc.NOTE: Why should
Component.onBeforeRender()
not be used for this? Because if a component's visibility is controlled insideComponent.onBeforeRender()
, once invisible the component will never become visible again.- Overrides:
onConfigure
in classComponent
-
dirty
- See Also:
-
setFreezePageId
Description copied from interface:IManageablePage
Sets whether or not the page is allowed to change its page id. Implementations of this interface usually change their page id once a change to the data structure is made and historical record of the current state needs to be kept (usually to be accessible via the back button). Keeping a historical record is usually achieved by simply incrementing the page id to the next unique number, so when the implementation is stored it is done so in a new slot. This method is useful when for some reason we do not want the implementation to change its page id under any circumstances. One concrete example is an AJAX request. Suppose the page with id 10 was written out with callbacks pointing to id 10. Suppose that the user executed some AJAX callbacks which have changed the page id to 15. Now, the user clicks a non-AJAX link that was never updated by an AJAX update and still points to id 10 - which causes the state of the page to be rolled back - which is usually undesirable as all changes made to the page by AJAX requests are lost. So, instead, whatever is invoking the execution of the AJAX request on the page can use this method to tell the page to not update its page id thereby solving the problem.- Specified by:
setFreezePageId
in interfaceIManageablePage
- Returns:
- previous state
-
dirty
Mark this page as modified in the session. If versioning is supported then a new version of the page will be stored inpage store
- Parameters:
isInitialization
- a flag whether this is a page instantiation
-
onInitialize
Description copied from class:Component
This method is meant to be used as an alternative to initialize components. Usually the component's constructor is used for this task, but sometimes a component cannot be initialized in isolation, it may need to access its parent component or its markup in order to fully initialize. This method is invoked once per component's lifecycle when a path exists from this component to thePage
thus providing the component with an atomic callback when the component's environment is built out.Overrides must call super#
Component.onInitialize()
. Usually this should be the first thing an override does, much like a constructor.Parent containers are guaranteed to be initialized before their children
It is safe to use
Component.getPage()
in this methodNOTE:The timing of this call is not precise, the contract is that it is called sometime before
Component.onBeforeRender()
.- Overrides:
onInitialize
in classMarkupContainer
-
getAutoIndex
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
-
getId
Description copied from class:Component
Gets the id of this component.- Specified by:
getId
in interfaceIRequestableComponent
- Overrides:
getId
in classComponent
- Returns:
- The id of this component
-
getPageClass
- Returns:
- page class
-
getSizeInBytes
- Overrides:
getSizeInBytes
in classComponent
- Returns:
- Size of this page in bytes
-
getStatelessHint
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.- Overrides:
getStatelessHint
in classComponent
- Returns:
- whether the component can be stateless
- See Also:
-
hierarchyAsString
- Returns:
- This page's component hierarchy as a string
-
isBookmarkable
Bookmarkable page can be instantiated using a bookmarkable URL.- Specified by:
isBookmarkable
in interfaceIRequestablePage
- Returns:
- Returns true if the page is bookmarkable.
-
isErrorPage
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.
-
isPageStateless
Gets whether the page is stateless. Components on stateless page must not render any stateful urls, and components on stateful page must not render any stateless urls. Stateful urls are urls, which refer to a certain (current) page instance.- Specified by:
isPageStateless
in interfaceIManageablePage
- Returns:
- Whether this page is stateless
-
setNumericId
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.- Parameters:
id
- The id
-
setStatelessHint
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
-
toString
Get the string representation of this container.- Overrides:
toString
in classMarkupContainer
- Returns:
- String representation of this container
-
componentChanged
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:
component
-parent
-
-
internalOnModelChanged
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.- Overrides:
internalOnModelChanged
in classComponent
- See Also:
-
onBeforeRender
Description copied from class:Component
Called on all visible components before any component is rendered.NOTE: If you override this, you *must* call super.onBeforeRender() within your implementation. Because this method is responsible for cascading
Changes to the component tree can be made only before calling super.onBeforeRender().Component.onBeforeRender()
call to its children it is strongly recommended that super call is made at the end of the override.- Overrides:
onBeforeRender
in classComponent
- See Also:
-
onAfterRender
Description copied from class:Component
Called immediately after a component and all its children have been rendered, regardless of any exception.- Overrides:
onAfterRender
in classComponent
-
onDetach
Description copied from class:Component
Called to allow a component to detach resources after use. Overrides of this method MUST call the super implementation, the most logical place to do this is the last line of the override method.- Overrides:
onDetach
in classMarkupContainer
-
onRender
Description copied from class:Component
Implementation that renders this component.- Overrides:
onRender
in classMarkupContainer
-
getMarkupType
Description copied from class:MarkupContainer
Get the type of associated markup for this component. The markup type for a component is independent of whether or not the component actually has an associated markup resource file (which is determined at runtime).- Overrides:
getMarkupType
in classMarkupContainer
- Returns:
- The type of associated markup for this component (for example, "html", "wml" or "vxml"). If there is no markup type for a component, null may be returned, but this means that no markup can be loaded for the class. Null is also returned if the component, or any of its parents, has not been added to a Page.
-
getPageReference
Gets page instance's unique identifier- Returns:
- instance unique identifier
-
getPageId
- Specified by:
getPageId
in interfaceIManageablePage
- Returns:
- A unique identifier for this page map entry
-
getRenderCount
Description copied from interface:IRequestablePage
Returns the number of times this page has been rendered. The number will be appended to request listener links in order to prevent invoking listeners from staled page version.For example, the same page might have been rendered in two separate tabs. Page render doesn't change page id, but it can modify component hierarchy. Request listeners on such page should only work in tab where the page was rendered most recently.
- Specified by:
getRenderCount
in interfaceIRequestablePage
- Returns:
- render count
-
setWasCreatedBookmarkable
THIS METHOD IS NOT PART OF WICKET API. DO NOT USE! Sets the flag that determines whether or not this page was created using one of its bookmarkable constructors- Parameters:
wasCreatedBookmarkable
-
-
wasCreatedBookmarkable
Checks if this page was created using one of its bookmarkable constructors- Specified by:
wasCreatedBookmarkable
in interfaceIRequestablePage
- Returns:
true
if this page has been created by a bookmarkable URL,false
otherwise.- See Also:
-
renderPage
Description copied from interface:IRequestablePage
Renders the page- Specified by:
renderPage
in interfaceIRequestablePage
-
wasRendered
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.- Parameters:
component
-- Returns:
- if this component was render in this page
-