org.apache.wicket
Class Page

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.Page
All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IConverterLocator, IRedirectListener, IRequestListener, IHeaderContributor, IManageablePage, IRequestableComponent, IRequestablePage, IHierarchical<Component>, IClusterable
Direct Known Subclasses:
WebPage

public abstract class Page
extends MarkupContainer
implements IRedirectListener, IRequestablePage

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).

Page has the following differences to Components main concepts:

Author:
Jonathan Locke, Chris Turner, Eelco Hillenius, Johan Compagner
See Also:
WebPage, MarkupContainer, CompoundPropertyModel, Component, Serialized Form

Field Summary
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Fields inherited from interface org.apache.wicket.IRedirectListener
INTERFACE
 
Constructor Summary
protected Page()
          Constructor.
protected Page(IModel<?> model)
          Constructor.
protected Page(PageParameters parameters)
          The PageParameters parameter will be stored in this page and then those parameters will be used to create stateless links to this bookmarkable page.
 
Method Summary
protected  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.
 void componentRendered(Component component)
          Adds a component to the set of rendered components.
 void detachModels()
          Detaches any attached models referenced by this page.
 void dirty()
           
 void dirty(boolean isInitialization)
          Mark this page as modified in the session.
 void endComponentRender(Component component)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 int getAutoIndex()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 String getId()
          Gets the id of this component.
 MarkupType getMarkupType()
          Get the type of associated markup for this component.
 Class<? extends Page> getPageClass()
           
 int getPageId()
           
 PageParameters getPageParameters()
          The PageParameters object that was used to construct this page.
 PageReference getPageReference()
          Gets page instance's unique identifier
 int getRenderCount()
          Returns the number of times this page has been rendered.
 long getSizeInBytes()
           
 boolean getStatelessHint()
          Returns whether the page should try to be stateless.
 String hierarchyAsString()
           
protected  void internalOnModelChanged()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void internalPrepareForRender(boolean setRenderingFlag)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 boolean isBookmarkable()
          Bookmarkable page can be instantiated using a bookmarkable URL.
 boolean isErrorPage()
          Override this method and return true if your page is used to display Wicket errors.
 boolean isPageStateless()
          Gets whether the page is stateless.
protected  void onAfterRender()
          Called just after a component is rendered.
protected  void onBeforeRender()
          Called just before a component is rendered only if the component is visible.
protected  void onDetach()
          Called to allow a component to detach resources after use.
protected  void onInitialize()
          This method is meant to be used as an alternative to initialize components.
 void onRedirect()
          Redirect to this page.
protected  void onRender()
          Implementation that renders this component.
 void renderPage()
          Renders the page
 boolean setFreezePageId(boolean freeze)
          Sets whether or not the page is allowed to change its page id.
 void setNumericId(int id)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void setStatelessHint(boolean value)
          Sets whether the page should try to be stateless.
 void setWasCreatedBookmarkable(boolean wasCreatedBookmarkable)
          Sets the flag that determins whether or not this page was created using one of its bookmarkable constructors
 void startComponentRender(Component component)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 String toString()
          Get the string representation of this container.
 boolean wasCreatedBookmarkable()
          Checks if this page was created using one of its bookmarkable constructors
 boolean wasRendered(Component component)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, visitChildren, visitChildren, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, 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, 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, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onComponentTag, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, 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.request.component.IRequestableComponent
detach, get, getBehaviorById, getBehaviorId, getPage, getPageRelativePath
 
Methods inherited from interface org.apache.wicket.page.IManageablePage
detach
 

Constructor Detail

Page

protected Page()
Constructor.


Page

protected Page(IModel<?> model)
Constructor.

Parameters:
model - See Component
See Also:
Component.Component(String, IModel)

Page

protected Page(PageParameters parameters)
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
Method Detail

getPageParameters

public PageParameters getPageParameters()
The PageParameters object that was used to construct this page. This will be used in creating stateless/bookmarkable links to this page

Specified by:
getPageParameters in interface IRequestablePage
Returns:
PageParameters The construction page parameter

componentRendered

public final void componentRendered(Component component)
Adds a component to the set of rendered components.

Parameters:
component - The component that was rendered

detachModels

public void detachModels()
Detaches any attached models referenced by this page.

Overrides:
detachModels in class Component

internalPrepareForRender

public void internalPrepareForRender(boolean setRenderingFlag)
Description copied from class: Component
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!

Prepares the component and it's children for rendering. On whole page render this method must be called on the page. On AJAX request, this method must be called on the updated component.

Overrides:
internalPrepareForRender in class Component
Parameters:
setRenderingFlag - Whether to set the rendering flag. This must be true if the page is about to be rendered. However, there are usecases to call this method without an immediate render (e.g. on stateless listener request target to build the component hierarchy), in that case setRenderingFlag should be false.
See Also:
Component.internalPrepareForRender(boolean)

dirty

public final void dirty()
See Also:
dirty(boolean)

setFreezePageId

public boolean setFreezePageId(boolean freeze)
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 interface IManageablePage
Returns:
previous state

dirty

public void dirty(boolean isInitialization)
Mark this page as modified in the session. If versioning is supported then a new version of the page will be stored in page store

Parameters:
isInitialization - a flag whether this is a page instantiation

onInitialize

protected void 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 the Page 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 method

NOTE:The timing of this call is not precise, the contract is that it is called sometime before Component.onBeforeRender().

Overrides:
onInitialize in class Component

endComponentRender

public final void endComponentRender(Component component)
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.

Parameters:
component -

getAutoIndex

public final int 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

public final String getId()
Description copied from class: Component
Gets the id of this component.

Specified by:
getId in interface IRequestableComponent
Overrides:
getId in class Component
Returns:
The id of this component
See Also:
Component.getId()

getPageClass

public final Class<? extends Page> getPageClass()
Returns:
page class

getSizeInBytes

public final long getSizeInBytes()
Overrides:
getSizeInBytes in class Component
Returns:
Size of this page in bytes

getStatelessHint

public final boolean 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 class Component
Returns:
whether the component can be stateless
See Also:
Component.getStatelessHint()

hierarchyAsString

public final String hierarchyAsString()
Returns:
This page's component hierarchy as a string

isBookmarkable

public boolean isBookmarkable()
Bookmarkable page can be instantiated using a bookmarkable URL.

Specified by:
isBookmarkable in interface IRequestablePage
Returns:
Returns true if the page is bookmarkable.

isErrorPage

public boolean 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

public final boolean 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 interface IManageablePage
Returns:
Whether this page is stateless

onRedirect

public final void onRedirect()
Redirect to this page.

Specified by:
onRedirect in interface IRedirectListener
See Also:
IRedirectListener.onRedirect()

setNumericId

public final void setNumericId(int id)
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

public final void setStatelessHint(boolean value)
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

startComponentRender

public final void startComponentRender(Component component)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL. This method is called when a component will be rendered standalone.

Parameters:
component -

toString

public String toString()
Get the string representation of this container.

Overrides:
toString in class MarkupContainer
Returns:
String representation of this container
See Also:
Component.toString()

componentChanged

protected 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. 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

protected final void internalOnModelChanged()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.

Overrides:
internalOnModelChanged in class Component
See Also:
Component.internalOnModelChanged()

onBeforeRender

protected void onBeforeRender()
Description copied from class: Component
Called just before a component is rendered only if the component is visible.

NOTE: If you override this, you *must* call super.onBeforeRender() within your implementation. Because this method is responsible for cascading Component.onBeforeRender() call to its children it is strongly recommended that super call is made at the end of the override.

Changes to the component tree can be made only before calling super.onBeforeRender().

Overrides:
onBeforeRender in class Component
See Also:
Component.onBeforeRender()

onAfterRender

protected void onAfterRender()
Description copied from class: Component
Called just after a component is rendered.

Overrides:
onAfterRender in class Component
See Also:
Component.onAfterRender()

onDetach

protected void 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 class Component
See Also:
Component.onDetach()

onRender

protected void onRender()
Description copied from class: Component
Implementation that renders this component.

Overrides:
onRender in class MarkupContainer
See Also:
MarkupContainer.onRender()

getMarkupType

public MarkupType getMarkupType()
Description copied from class: MarkupContainer
Get the type of associated markup for this component.

Overrides:
getMarkupType in class MarkupContainer
Returns:
The type of associated markup for this component (for example, "html", "wml" or "vxml"). 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). 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.
See Also:
MarkupContainer.getMarkupType()

getPageReference

public PageReference getPageReference()
Gets page instance's unique identifier

Returns:
instance unique identifier

getPageId

public int getPageId()
Specified by:
getPageId in interface IManageablePage
Returns:
A unique identifier for this page map entry
See Also:
IManageablePage.getPageId()

getRenderCount

public int getRenderCount()
Description copied from interface: IRequestablePage
Returns the number of times this page has been rendered. The number will be appended to listener interface links in order to prevent invoking listeners from staled page version.

For example a same page might have been rendered in two separate tabs. Page render doesn't change page id but it can modify component hierarchy. Listener interface links on such page should only work in tab where the page was rendered most recently.

Specified by:
getRenderCount in interface IRequestablePage
Returns:
render count

setWasCreatedBookmarkable

public final void setWasCreatedBookmarkable(boolean wasCreatedBookmarkable)
Sets the flag that determins whether or not this page was created using one of its bookmarkable constructors

Parameters:
wasCreatedBookmarkable -

wasCreatedBookmarkable

public final boolean wasCreatedBookmarkable()
Checks if this page was created using one of its bookmarkable constructors

Specified by:
wasCreatedBookmarkable in interface IRequestablePage
Returns:
true if this page has been created by a bookmarkable URL, false otherwise.
See Also:
IRequestablePage.wasCreatedBookmarkable()

renderPage

public void renderPage()
Description copied from interface: IRequestablePage
Renders the page

Specified by:
renderPage in interface IRequestablePage
See Also:
IRequestablePage.renderPage()

wasRendered

public final boolean wasRendered(Component component)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.

Parameters:
component -
Returns:
if this component was render in this page


Copyright © 2006–2017 Apache Software Foundation. All rights reserved.