- All Implemented Interfaces:
Serializable
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IMetadataContext<Serializable,
,Component> IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
- Direct Known Subclasses:
MarkupContainer
,WebComponent
- Identity - All Components must have a non-null id which is retrieved by calling
getId(). The id must be unique within the
MarkupContainer
that holds the Component, but does not have to be globally unique or unique within a Page's component hierarchy. - Hierarchy - A component has a parent which can be retrieved with
getParent()
. If a component is an instance of MarkupContainer, it may have children. In this way it has a place in the hierarchy of components contained on a given page.The path from the Page at the root of the component hierarchy to a given Component is simply the concatenation with colon separators of each id along the way. For example, the path "a:b:c" would refer to the component named "c" inside the MarkupContainer named "b" inside the container named "a". The path to a component can be retrieved by calling
getPath()
. To get a Component path relative to the page that contains it, you can callgetPageRelativePath()
. - LifeCycle - Components participate in the following lifecycle phases:
- Construction - A Component is constructed with the Java language new operator.
Children may be added during construction if the Component is a MarkupContainer.
IComponentInstantiationListener
s are notified of component instantiation.onInitialize()
is called on the component as soon as the component is part of a page's component tree. At this state the component is able to access its markup. - Request Handling - An incoming request is processed by a protocol request handler such
as
WicketFilter
. An associated Application object createsSession
,Request
andResponse
objects for use by a given Component in updating its model and rendering a response. These objects are stored inside a container calledRequestCycle
which is accessible viagetRequestCycle()
. The convenience methodsgetRequest()
,getResponse()
andgetSession()
provide easy access to the contents of this container. - Listener Invocation - If the request references an
IRequestListener
on an existing Component (or one of itsBehavior
s, see below), that listener is notified, allowing arbitrary user code to handle events such as link clicks or form submits. Although arbitrary listeners are supported in Wicket, the need to implement a new class of listener is unlikely for a web application and even the need to implement a listener interface directly is highly discouraged. Instead, calls to listeners are routed through logic specific to the event, resulting in calls to user code through other overridable methods. SeeForm
for an example of a component which listens for events viaIRequestListener
. - Rendering - Before a page or part of a page (in case of Ajax updates) is rendered, all
containing components are able to prepare for rendering via two hook methods:
onConfigure()
(regardless whether they are visible or not) andonBeforeRender()
(if visible only) .
A markup response is generated by the Component viarender()
, which calls subclass implementation code contained inonRender()
. Once this phase begins, a Component becomes immutable. Attempts to alter the Component will result in a WicketRuntimeException. - Detachment - Each request cycle finishes by detaching all touched components.
Subclasses should clean up their state by overriding
onDetach()
or more specificallydetachModels()
if they keep references to models beside the default model.
- Construction - A Component is constructed with the Java language new operator.
Children may be added during construction if the Component is a MarkupContainer.
- Visibility - If a component is not visible (see
setVisible(boolean)
) it will not render a response (nor will their children). - Enabling - Component subclasses take into account their enabled state (see
setEnabled(boolean)
when rendering, and in case of aFormComponent
will not not update its model while the request is handled. - Models - The primary responsibility of a component is to use its model (an object that
implements
IModel
) to render a response in an appropriate markup language, such as HTML. In addition,FormComponent
s know how to update their models based on request information, seeFormComponent.updateModel()
. Since the IModel interface is a wrapper around another object, a convenience methodgetDefaultModelObject()
is provided to retrieve the object from its IModel wrapper. A further convenience method,getDefaultModelObjectAsString()
, is provided for the very common operation of converting the wrapped object to a String.
The component's model can be passed in the constructor or set viasetDefaultModel(IModel)
. In neither case a model can be created on demand withinitModel()
.
Note that a component can have more models besides its default model. - Behaviors - You can add multiple
Behavior
s to any component if you need to dynamically alter the behavior of components, e.g. manipulate attributes of the markup tag to which a Component is attached. Behaviors take part in the component's lifecycle through various callback methods. - Locale - The Locale for a Component is available through
getLocale()
, which delegates to its parent's locale, finally consulting theSession
's locale. - Style - The Session's style ("skin") is available through
getStyle()
. Styles are intended to give a particular look to all components or resources in a session that is independent of its Locale. For example, a style might be a set of resources, including images and markup files, which gives the design look of "ocean" to the user. If the Session's style is set to "ocean" and these resources are given names suffixed with "_ocean", Wicket's resource management logic will prefer these resources to other resources, such as default resources, which are not as good of a match. - Variation - Whereas styles are Session (user) specific, variations are component
specific. E.g. if the Style is "ocean" and
getVariation()
returnss "NorthSea", than the resources are given the names suffixed with "_ocean_NorthSea". - String Resources - Components can have associated String resources via the
Application's Localizer, which is available through the method
getLocalizer()
. The convenience methodsgetString(String key)
andgetString(String key, IModel model)
wrap the identical methods on the Application Localizer for easy access in Components. - Feedback Messages - The
debug(Serializable)
,info(Serializable)
,warn(Serializable)
,error(java.io.Serializable)
andfatal(Serializable)
methods associate feedback messages with a Component. It is generally not necessary to use these methods directly since Wicket validators automatically register feedback messages on Components. Feedback message for a given Component can be retrieved withgetFeedbackMessages()
. - Versioning - Pages are the unit of versioning in Wicket, but fine-grained control of
which Components should participate in versioning is possible via the
setVersioned(boolean)
method. The versioning participation of a given Component can be retrieved withisVersioned()
. - Page - The Page containing any given Component can be retrieved by calling
getPage()
. If the Component is not attached to a Page, an IllegalStateException will be thrown. An equivalent method,findPage()
is available for special circumstances where it might be desirable to get a null reference back instead. - Application - The
getApplication()
method provides convenient access to theApplication
for a Component. - AJAX support- Components can be re-rendered after the whole Page has been rendered at least once by calling doRender().
- Security - All components are subject to an
IAuthorizationStrategy
which controls instantiation, visibility and enabling. SeeSimplePageAuthorizationStrategy
for a simple implementation.
- Author:
- Jonathan Locke, Chris Turner, Eelco Hillenius, Johan Compagner, Juergen Donnerstag, Igor Vaynberg (ivaynberg)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Action
Action used with IAuthorizationStrategy to determine whether a component is allowed to be enabled.protected static final int
onInitialize calledprotected static final int
Reserved subclass-definable flag bitprotected static final int
Reserved subclass-definable flag bitprotected static final int
Reserved subclass-definable flag bitprotected static final int
Reserved subclass-definable flag bitprotected static final int
Reserved subclass-definable flag bitprotected static final int
Reserved subclass-definable flag bitstatic final String
Path segment that represents this component's parentstatic final char
Separator for component pathsstatic final Action
Action used with IAuthorizationStrategy to determine whether a component and its children are allowed to be rendered.protected static final short
protected static final short
This flag tracks if removals have been set on this component. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a behavior modifier to the component.protected final void
TODO WICKET-NG rename to something more useful - like componentChanged(), this method used to be called with a Change object Adds state change to page.final void
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.boolean
Checks whether or not anIRequestListener
can be invoked on this component.boolean
protected final void
checkComponentTag
(ComponentTag tag, String name) Checks whether the given type has the expected name.protected final void
checkComponentTagAttribute
(ComponentTag tag, String key, String... values) Checks that a given tag has a required attribute value.protected void
checkHierarchyChange
(Component component) Checks whether the hierarchy may be changed at all, and throws an exception if this is not the case.final void
Clears any data about previously intercepted page.final void
TriggersonConfigure()
to be invoked on this component if it has not already during this request.final void
Redirects to any intercept page previously specified by a call toredirectToInterceptPage(Page)
.protected IConverter<?>
createConverter
(Class<?> type) Factory method for converters to be used by this component, returnsnull
by default.final void
debug
(Serializable message) Registers a debug feedback message for this componentfinal void
detach()
Detaches the component.protected void
Detaches the model for this component if it is detachable.void
Detaches all modelsfinal boolean
Determines whether or not a component should be visible, taking into account all the factors:isVisible()
,isVisibilityAllowed()
,isRenderAllowed()
final void
error
(Serializable message) Registers an error feedback message for this componentprotected final String
exceptionMessage
(String message) Suffixes an exception message with useful information about this. component.final void
fatal
(Serializable message) Registers a fatal feedback message for this componentprotected final MarkupStream
Finds the markup stream for this component.protected final Page
findPage()
If this Component is a Page, returns self.final <Z> Z
findParent
(Class<Z> c) Finds the first container parent of this component of the given class.final MarkupContainer
Gets the component at the given path.final String
Returns the id of the markup region that will be updated via ajax.final Application
Gets interface to application that this component is a part of.final Behavior
getBehaviorById
(int id) Gets the behavior for the specified idfinal int
getBehaviorId
(Behavior behavior) Gets a stable id for the specified non-temporary behavior.Gets the currently coupledBehavior
s as an unmodifiable list.getBehaviors
(Class<M> type) Gets the subset of the currently coupledBehavior
s that are of the provided type as an unmodifiable list.final String
<C> IConverter<C>
getConverter
(Class<C> type) Get the converter that should be used by this component, delegates tocreateConverter(Class)
and then to the application'sIConverterLocator
.final IModel<?>
Gets the model.final Object
Gets the backing model object.final String
Gets a model object as a string.final String
getDefaultModelObjectAsString
(Object modelObject) Gets a model object as a string.final boolean
Gets whether model strings should be escaped.Gets feedback messages for this component.protected final boolean
getFlag
(int flag) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.getId()
Gets the id of this component.final IModel<?>
protected final IModel<?>
getInnermostModel
(IModel<?> model) Finds the innermost IModel object for an IModel that might contain nested IModel(s).Gets the locale for this component.final Localizer
Convenience method to provide easy access to the localizer object within any component.Get the Markup associated with the Component.final ValueMap
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.Retrieves id by which this component is represented within the markup.getMarkupId
(boolean createIfDoesNotExist) Retrieves id by which this component is represented within the markup.final String
final Object
Get the markupIdprotected final IMarkupSourcingStrategy
Get the markup sourcing strategy for the component.protected final ComponentTag
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.final <M extends Serializable>
MgetMetaData
(MetaDataKey<M> key) Gets metadata for this component using the given key.Gets the component's current model comparator.final boolean
Gets whether or not component will output id attribute into the markup. id attribute will be set to the value returned fromgetMarkupId()
.final boolean
Gets whether or not an invisible component will render a placeholder tag.final Page
getPage()
Gets the page holding this component.final String
Gets the path to this component relative to its containing page, i.e. without leading page id.final MarkupContainer
Gets any parent container, or null if there is none.final String
getPath()
Gets this component's path.final boolean
If false the component's tag will be printed as well as its body (which is default).final Request
final RequestCycle
Gets the active request cycle for this componentprotected final boolean
getRequestFlag
(short flag) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.final Response
Gets the current Session object.long
protected boolean
Returns whether the component can be stateless.final String
final String
final String
final String
getStyle()
A convenience method to access the Sessions's style.Gets the variation string of this component that will be used to look up markup for this component.final boolean
Gets whether this component was rendered at least once.final boolean
final boolean
final void
info
(Serializable message) Registers an informational feedback message for this componentprotected IModel<?>
Called when a null model is about to be retrieved in order to allow a subclass to provide an initial model.void
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.protected void
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.protected final void
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.void
internalRenderHead
(HtmlHeaderContainer container) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.final boolean
isActionAuthorized
(Action action) Authorizes an action for a component.final boolean
isAuto()
protected boolean
isBehaviorAccepted
(Behavior behavior) Components are allowed to reject behavior modifiers.final boolean
boolean
Gets whether this component is enabled.boolean
Calculates enabled state of the component taking its hierarchy into account.protected final boolean
If true, all attribute modifiers will be ignoredfinal boolean
Checks if the component has been initialized -onInitialize()
has been calledfinal boolean
Checks the security strategy if theRENDER
action is allowed on this componentfinal boolean
Says if the component is rendering currently.final boolean
Returns if the component is stateless or not.boolean
final boolean
Gets whether or not visibility is allowed on this component.boolean
Gets whether this component and any children are visible.final boolean
Checks if the component itself and all its parents are visible.final void
markRendering
(boolean setRenderingFlag) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.final void
Called to indicate that the model content for this component has been changedfinal void
Called to indicate that the model content for this component is about to changeprotected IMarkupSourcingStrategy
IfgetMarkupSourcingStrategy()
returns null, this method will be called.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
Processes the component tag.void
onComponentTagBody
(MarkupStream markupStream, ComponentTag openTag) Processes the body.protected void
Called on all components before any component is rendered.protected void
onDetach()
Called to allow a component to detach resources after use.void
Called when an event is sent to this sinkprotected void
This method is meant to be used as an alternative to initialize components.protected void
Called anytime a model is changed after the change has occurredprotected void
Called anytime a model is changed, but before the change actually occursprotected void
onReAdd()
This method is called whenever a component is re-added to the page's component tree, if it had been removed at some earlier time, i.e., if it is already initialized (seeisInitialized()
).protected void
onRemove()
Called to notify the component it is being removed from the component hierarchy Overrides of this method MUST call the super implementation, the most logical place to do this is the last line of the override method.protected abstract void
onRender()
Implementation that renders this component.final void
redirectToInterceptPage
(Page page) Redirects browser to an intermediate page such as a sign-in page.final void
remove()
Removes this component from its parent.Removes behavior from componentfinal void
render()
Render this component and all its children.protected final void
Writes a simple tag out to the response stream.final void
rendered()
Called to indicate that a component has been rendered.void
renderHead
(IHeaderResponse response) Render to the web response whatever the component wants to contribute to the head section.final void
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.protected void
renderPlaceholderTag
(ComponentTag tag, Response response) Renders a placeholder tag for the component when it is invisible andsetOutputMarkupPlaceholderTag(boolean)
has been called withtrue
.protected final void
replaceComponentTagBody
(MarkupStream markupStream, ComponentTag tag, CharSequence body) Replaces the body with the given one.replaceWith
(Component replacement) Replaces this component with another.final boolean
sameInnermostModel
(Component component) final boolean
sameInnermostModel
(IModel<?> model) final <T> void
send
(IEventSink sink, Broadcast type, T payload) Sends an eventprotected final Component
setAuto
(boolean auto) setDefaultModel
(IModel<?> model) Sets the given model.final Component
setDefaultModelObject
(Object object) Sets the backing model object.final Component
setEnabled
(boolean enabled) Sets whether this component is enabled.final Component
setEscapeModelStrings
(boolean escapeMarkup) Sets whether model strings should be escaped.protected final Component
setFlag
(int flag, boolean set) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.protected final Component
setIgnoreAttributeModifier
(boolean ignore) If true, all attribute modifiers will be ignoredfinal Component
setMarkup
(IMarkupFragment markup) Set the markup for the component.setMarkupId
(String markupId) Sets this component's markup id to a user defined value.final void
setMarkupIdImpl
(Object markupId) Set markup ID, which must be String or Integerfinal <M extends Serializable>
ComponentsetMetaData
(MetaDataKey<M> key, M object) Sets the metadata for this component using the given key.final Component
setOutputMarkupId
(boolean output) Sets whether or not component will output id attribute into the markup. id attribute will be set to the value returned fromgetMarkupId()
.final Component
setOutputMarkupPlaceholderTag
(boolean outputTag) Render a placeholder tag when the component is not visible.final void
setParent
(MarkupContainer parent) THIS IS A WICKET INTERNAL API.final Component
setRenderBodyOnly
(boolean renderTag) If false the component's tag will be printed as well as its body (which is default).final <C extends IRequestablePage>
voidsetResponsePage
(Class<C> cls) Sets the page that will respond to this requestfinal <C extends IRequestablePage>
voidsetResponsePage
(Class<C> cls, PageParameters parameters) Sets the page class and its parameters that will respond to this requestfinal void
Sets the page that will respond to this requestsetVersioned
(boolean versioned) final Component
setVisibilityAllowed
(boolean allowed) Sets whether or not this component is allowed to be visible.final Component
setVisible
(boolean visible) Sets whether this component and any children are visible.final void
success
(Serializable message) Registers an success feedback message for this componenttoString()
Gets the string representation of this component.toString
(boolean detailed) final <C extends Page>
CharSequenceurlFor
(Class<C> pageClass, PageParameters parameters) Returns a bookmarkable URL that references a given page class using a given set of page parameters.final CharSequence
urlFor
(IRequestHandler requestHandler) Returns a URL that references the given request target.final CharSequence
urlFor
(ResourceReference resourceReference, PageParameters parameters) Returns a URL that references a shared resource through the provided resource reference.final CharSequence
urlForListener
(Behavior behaviour, PageParameters parameters) Gets a URL for the listener interface on a behavior (e.g.final CharSequence
urlForListener
(PageParameters parameters) Gets a URL for thisIRequestListener
.final <R,
C extends MarkupContainer>
RvisitParents
(Class<C> parentClass, IVisitor<C, R> visitor) Traverses all parent components of the given class in this parentClass, calling the visitor's visit method at each one.final <R,
C extends MarkupContainer>
RvisitParents
(Class<C> parentClass, IVisitor<C, R> visitor, IVisitFilter filter) Traverses all parent components of the given class in this parentClass, calling the visitor's visit method at each one.final void
warn
(Serializable message) Registers a warning feedback message for this component.protected final <V> IModel<V>
-
Field Details
-
ENABLE
Action used with IAuthorizationStrategy to determine whether a component is allowed to be enabled.If enabling is authorized, a component may decide by itself (typically using it's enabled property) whether it is enabled or not. If enabling is not authorized, the given component is marked disabled, regardless its enabled property.
When a component is not allowed to be enabled (in effect disabled through the implementation of this interface), Wicket will try to prevent model updates too. This is not completely fail safe, as constructs like:
User u = (User)getModelObject(); u.setName("got you there!");
can't be prevented. Indeed it can be argued that any model protection is best dealt with in your model objects to be completely secured. Wicket will catch all normal framework-directed use though. -
PATH_SEPARATOR
Separator for component paths- See Also:
-
PARENT_PATH
Path segment that represents this component's parent- See Also:
-
RENDER
Action used with IAuthorizationStrategy to determine whether a component and its children are allowed to be rendered.There are two uses for this method:
- The 'normal' use is for controlling whether a component is rendered without having any effect on the rest of the processing. If a strategy lets this method return 'false', then the target component and its children will not be rendered, in the same fashion as if that component had visibility property 'false'.
- The other use is when a component should block the rendering of the whole page. So
instead of 'hiding' a component, what we generally want to achieve here is that we force the
user to logon/give-credentials for a higher level of authorization. For this functionality,
the strategy implementation should throw a
AuthorizationException
, which will then be handled further by the framework.
-
FLAG_RESERVED1
Reserved subclass-definable flag bit- See Also:
-
FLAG_RESERVED2
Reserved subclass-definable flag bit- See Also:
-
FLAG_RESERVED3
Reserved subclass-definable flag bit- See Also:
-
FLAG_RESERVED4
Reserved subclass-definable flag bit- See Also:
-
FLAG_RESERVED5
Reserved subclass-definable flag bit- See Also:
-
FLAG_INITIALIZED
onInitialize called- See Also:
-
FLAG_RESERVED8
Reserved subclass-definable flag bit- See Also:
-
RFLAG_CONTAINER_DEQUEING
- See Also:
-
RFLAG_CONTAINER_HAS_REMOVALS
This flag tracks if removals have been set on this component. Clearing this key is an expensive operation. With this flag this expensive call can be avoided.- See Also:
-
-
Constructor Details
-
Component
Constructor. All components have names. A component's id cannot be null. This is the minimal constructor of component. It does not register a model.- Parameters:
id
- The non-null id of this component- Throws:
WicketRuntimeException
- Thrown if the component has been given a null id.
-
Component
Constructor. All components have names. A component's id cannot be null. This constructor includes a model.- Parameters:
id
- The non-null id of this componentmodel
- The component's model- Throws:
WicketRuntimeException
- Thrown if the component has been given a null id.
-
-
Method Details
-
getMarkup
Get the Markup associated with the Component. If not subclassed, the parent container is asked to return the markup of this child component. Components like Panel and Border should return the "calling" markup fragment, e.g.<span wicket:id="myPanel">body</span>
. You may use Panel/Border/Enclosure.getMarkup(null) to return the associated markup file. And Panel/Border/Enclosure.getMarkup(child) will search the child in the appropriate markup fragment.- Returns:
- The markup fragment
- See Also:
-
getMarkupIdFromMarkup
- Returns:
- The 'id' attribute from the associated markup tag
-
setMarkup
Set the markup for the component. Note that the component's markup variable is transient and thus must only be used for one render cycle. E.g. auto components are using it. You may also it if you subclassed getMarkup().- Parameters:
markup
-
-
onConfigure
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
onBeforeRender()
NOTE: Why this method is preferrable to directly overriding
isVisible()
andisEnabled()
? 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 inconfigure()
javadoc.NOTE: Why should
onBeforeRender()
not be used for this? Because if a component's visibility is controlled insideonBeforeRender()
, once invisible the component will never become visible again. -
onInitialize
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#
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
getPage()
in this methodNOTE:The timing of this call is not precise, the contract is that it is called sometime before
onBeforeRender()
. -
isInitialized
Checks if the component has been initialized -onInitialize()
has been called- Returns:
true
if component has been initialized
-
internalInitialize
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT! Used to callonInitialize()
-
beforeRender
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT! Called on all components before any component is rendered. Calls hooksconfigure()
and (if visible)onBeforeRender()
and delegates tobeforeRender()
of all child components. -
configure
TriggersonConfigure()
to be invoked on this component if it has not already during this request.This method should be invoked before any calls to
isVisible()
orisEnabled()
. Usually this method will be called by the framework before the component is rendered and so users should not need to call it; however, in cases where visibility or enabled or other state of one component depends on the state of another this method should be manually invoked on the other component by the user. EG to link visiliby of two markup containers the following should be done:final WebMarkupContainer source=new WebMarkupContainer("a") { protected void onConfigure() { setVisible(Math.rand()>0.5f); } }; WebMarkupContainer linked=new WebMarkupContainer("b") { protected void onConfigure() { source.configure(); // make sure source is configured setVisible(source.isVisible()); } }
-
continueToOriginalDestination
Redirects to any intercept page previously specified by a call toredirectToInterceptPage(Page)
. The redirect is done by throwing an exception. If there is no intercept page no exception will be thrown and the program flow will continue uninterrupted. Example:add(new Link("login") { protected void onClick() { if (authenticate()) { continueToOriginalDestination(); // if we reach this line there was no intercept page, so go to home page setResponsePage(WelcomePage.class); } } });
- See Also:
-
clearOriginalDestination
Clears any data about previously intercepted page. -
debug
Registers a debug feedback message for this component- Specified by:
debug
in interfaceIFeedbackContributor
- Parameters:
message
- The feedback message
-
detach
Detaches the component. This is called at the end of the request for all the pages that are touched in that request.- Specified by:
detach
in interfaceIRequestableComponent
-
detachModels
Detaches all models -
error
Registers an error feedback message for this component- Specified by:
error
in interfaceIFeedbackContributor
- Parameters:
message
- The feedback message
-
fatal
Registers a fatal feedback message for this component- Specified by:
fatal
in interfaceIFeedbackContributor
- Parameters:
message
- The feedback message
-
findParent
Finds the first container parent of this component of the given class.- Type Parameters:
Z
- type of parent- Parameters:
c
- MarkupContainer class to search for- Returns:
- First container parent that is an instance of the given class, or null if none can be found
-
findParentWithAssociatedMarkup
- Returns:
- The nearest markup container with associated markup
-
getApplication
Gets interface to application that this component is a part of.- Returns:
- The application associated with the session that this component is in.
- See Also:
-
getClassRelativePath
- Returns:
- A path of the form [page-class-name]:[page-relative-path]
- See Also:
-
getConverter
Get the converter that should be used by this component, delegates tocreateConverter(Class)
and then to the application'sIConverterLocator
.- Specified by:
getConverter
in interfaceIConverterLocator
- Type Parameters:
C
- The object to convert from and to String- Parameters:
type
- The type to convert to- Returns:
- The converter that should be used by this component
-
createConverter
Factory method for converters to be used by this component, returnsnull
by default.- Parameters:
type
- The type to convert to- Returns:
- a converter to be used by this component
-
getEscapeModelStrings
Gets whether model strings should be escaped.- Returns:
- Returns whether model strings should be escaped
-
getId
Gets the id of this component.- Specified by:
getId
in interfaceIRequestableComponent
- Returns:
- The id of this component
-
getInnermostModel
- Returns:
- Innermost model for this component
-
getLocale
Gets the locale for this component. By default, it searches its parents for a locale. If no parents (it's a recursive search) returns a locale, it gets one from the session.- Returns:
- The locale to be used for this component
- See Also:
-
getLocalizer
Convenience method to provide easy access to the localizer object within any component.- Returns:
- The localizer object
-
getMarkupTag
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT! Get the first component tag in the associated markup- Returns:
- first component tag
-
getMarkupAttributes
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT! Get a copy of the markup's attributes which are associated with the component.Modifications to the map returned don't change the tags attributes. It is just a copy.
Note: The component must have been added (directly or indirectly) to a container with an associated markup file (Page, Panel or Border).
- Returns:
- markup attributes
-
getMarkupIdImpl
Get the markupId- Returns:
- MarkupId
-
getMarkupId
Retrieves id by which this component is represented within the markup. This is either the id attribute set explicitly via a call tosetMarkupId(String)
, id attribute defined in the markup, or an automatically generated id - in that order.If no id is set and
createIfDoesNotExist
is false, this method will return null. Otherwise it will generate an id value which by default will be unique in the page. This is the preferred way as there is no chance of id collision. This will also enablesetOutputMarkupId(boolean)
.Note: This method should only be called after the component or its parent have been added to the page.
- Parameters:
createIfDoesNotExist
- When there is no existing markup id, determines whether it should be generated or whethernull
should be returned.- Returns:
- markup id of the component
-
getMarkupId
Retrieves id by which this component is represented within the markup. This is either the id attribute set explicitly via a call tosetMarkupId(String)
, id attribute defined in the markup, or an automatically generated id - in that order.If no explicit id is set this function will generate an id value that will be unique in the page. This is the preferred way as there is no chance of id collision. This will also enable
setOutputMarkupId(boolean)
.Note: This method should only be called after the component or its parent have been added to the page.
- Returns:
- markup id of the component
-
getMetaData
Gets metadata for this component using the given key.- Specified by:
getMetaData
in interfaceIMetadataContext<Serializable,
Component> - Type Parameters:
M
- The type of the metadata.- Parameters:
key
- The key for the data- Returns:
- The metadata or null of no metadata was found for the given key
- See Also:
-
getDefaultModel
Gets the model. It returns the object that wraps the backing model.- Returns:
- The model
-
getDefaultModelObject
Gets the backing model object. Unlike getDefaultModel().getObject(), this method returns null for a null model.- Returns:
- The backing model object
-
getDefaultModelObjectAsString
Gets a model object as a string. Depending on the "escape model strings" flag of the component, the string is either HTML escaped or not. "HTML escaped" meaning that only HTML sensitive chars are escaped but not all none-ascii chars. Proper HTML encoding should be used instead. In case you really need a fully escaped model string you may callStrings.escapeMarkup(CharSequence, boolean, boolean)
on the model string returned.- Returns:
- Model object for this component as a string
- See Also:
-
getDefaultModelObjectAsString
Gets a model object as a string. Depending on the "escape model strings" flag of the component, the string is either HTML escaped or not. "HTML escaped" meaning that only HTML sensitive chars are escaped but not all none-ascii chars. Proper HTML encoding should be used instead. In case you really need a fully escaped model string you may callStrings.escapeMarkup(CharSequence, boolean, boolean)
on the model string returned.- Parameters:
modelObject
- Model object to convert to string- Returns:
- The string
- See Also:
-
getOutputMarkupId
Gets whether or not component will output id attribute into the markup. id attribute will be set to the value returned fromgetMarkupId()
.- Returns:
- whether or not component will output id attribute into the markup
-
getOutputMarkupPlaceholderTag
Gets whether or not an invisible component will render a placeholder tag.- Returns:
- true if a placeholder tag should be rendered
-
getPage
Gets the page holding this component.- Specified by:
getPage
in interfaceIRequestableComponent
- Returns:
- The page holding this component
- Throws:
WicketRuntimeException
- Thrown if component is not yet attached to a Page.- See Also:
-
getPageRelativePath
Gets the path to this component relative to its containing page, i.e. without leading page id.- Specified by:
getPageRelativePath
in interfaceIRequestableComponent
- Returns:
- The path to this component relative to the page it is in
-
getParent
Gets any parent container, or null if there is none.- Specified by:
getParent
in interfaceIHierarchical<Component>
- Returns:
- Any parent container, or null if there is none
-
getPath
Gets this component's path.- Returns:
- Colon separated path to this component in the component hierarchy
-
getRenderBodyOnly
If false the component's tag will be printed as well as its body (which is default). If true only the body will be printed, but not the component's tag.- Returns:
- If true, the component tag will not be printed
-
getRequest
- Returns:
- The request for this component's active request cycle
-
getRequestCycle
Gets the active request cycle for this component- Returns:
- The request cycle
-
getResponse
- Returns:
- The response for this component's active request cycle
-
getSession
Gets the current Session object.- Returns:
- The Session that this component is in
-
getSizeInBytes
- Returns:
- Size of this Component in bytes. Returns
0
- if the size cannot be calculated for some reason
-
getString
- Parameters:
key
- Key of string resource in property file- Returns:
- The String
- See Also:
-
getString
- Parameters:
key
- The resource keymodel
- The model- Returns:
- The formatted string
- See Also:
-
getString
- Parameters:
key
- The resource keymodel
- The modeldefaultValue
- A default value if the string cannot be found- Returns:
- The formatted string
- See Also:
-
getStyle
A convenience method to access the Sessions's style.- Returns:
- The style of this component respectively the style of the Session.
- See Also:
-
getVariation
Gets the variation string of this component that will be used to look up markup for this component. Subclasses can override this method to define by an instance what markup variation should be picked up. By default it will return null or the value of a parent.- Returns:
- The variation of this component.
-
hasBeenRendered
Gets whether this component was rendered at least once.- Returns:
- true if the component has been rendered before, false if it is merely constructed
-
getFeedbackMessages
Gets feedback messages for this component. This method will instantiate aFeedbackMessages
instance and add it to the component metadata, even when called on a component that has no feedback messages, to avoid the overhead usehasFeedbackMessage()
- Returns:
- feedback messages instance
-
hasErrorMessage
- Returns:
- True if this component has an error message
-
hasFeedbackMessage
- Returns:
- True if this component has some kind of feedback message
-
info
Registers an informational feedback message for this component- Specified by:
info
in interfaceIFeedbackContributor
- Parameters:
message
- The feedback message
-
success
Registers an success feedback message for this component- Specified by:
success
in interfaceIFeedbackContributor
- Parameters:
message
- The feedback message
-
isActionAuthorized
Authorizes an action for a component.- Parameters:
action
- The action to authorize- Returns:
- True if the action is allowed
- Throws:
AuthorizationException
- Can be thrown by implementation if action is unauthorized
-
isEnableAllowed
- Returns:
- true if this component is authorized to be enabled, false otherwise
-
isEnabled
Gets whether this component is enabled. Specific components may decide to implement special behavior that uses this property, like web form components that add a disabled='disabled' attribute when enabled is false.- Returns:
- Whether this component is enabled.
-
isRenderAllowed
Checks the security strategy if theRENDER
action is allowed on this component- Returns:
- true if
RENDER
action is allowed, false otherwise
-
isStateless
Returns if the component is stateless or not. It checks the stateless hint if that is false it returns directly false. If that is still true it checks all its behaviors if they can be stateless.- Returns:
- whether the component is stateless.
-
isVersioned
- Returns:
true
if this component should notify its holding page about changes in its state. If aPage
is not versioned then it wont track changes in its components and will use the samePage.getPageId()
during its lifetime
-
isVisible
Gets whether this component and any children are visible.WARNING: this method can be called multiple times during a request. If you override this method, it is a good idea to keep it cheap in terms of processing. Alternatively, you can call
setVisible(boolean)
.- Returns:
- True if component and any children are visible
-
isVisibleInHierarchy
Checks if the component itself and all its parents are visible.- Returns:
- true if the component and all its parents are visible.
-
markRendering
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT! Sets the RENDERING flag and removes the PREPARED_FOR_RENDER flag on component and it's children.- Parameters:
setRenderingFlag
- if this is false only the PREPARED_FOR_RENDER flag is removed from component, the RENDERING flag is not set.
-
modelChanged
Called to indicate that the model content for this component has been changed -
modelChanging
Called to indicate that the model content for this component is about to change -
redirectToInterceptPage
Redirects browser to an intermediate page such as a sign-in page. The current request's URL is saved for future use by methodcontinueToOriginalDestination()
; only use this method when you plan to continue to the current URL at some later time; otherwise just set a new response page.- Parameters:
page
- The sign in page- See Also:
-
remove
Removes this component from its parent. It's important to remember that a component that is removed cannot be referenced from the markup still.You must not use this method in your callback to any of the
MarkupContainer.visitChildren(IVisitor)
methods. See WICKET-3329. -
renderPart
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!Renders this component as a part of a response - the caller has to make sure that this component is prepared for render.
- See Also:
-
render
Render this component and all its children. Always calls hookonAfterRender()
regardless of any exception. -
renderPlaceholderTag
Renders a placeholder tag for the component when it is invisible andsetOutputMarkupPlaceholderTag(boolean)
has been called withtrue
.- Parameters:
tag
- component tagresponse
- response
-
getAjaxRegionMarkupId
Returns the id of the markup region that will be updated via ajax. This can be different to the markup id of the component if aIAjaxRegionMarkupIdProvider
behavior has been added.- Returns:
- the markup id of the region to be updated via ajax.
-
internalRenderComponent
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!Renders the component at the current position in the given markup stream. The method onComponentTag() is called to allow the component to mutate the start tag. The method onComponentTagBody() is then called to permit the component to render its body.
-
rendered
Called to indicate that a component has been rendered. This method should only very rarely be called at all. Some components may render its children without calling render() on them. These components need to call rendered() to indicate that its child components were actually rendered, the framework would think they had never been rendered, and in development mode this would result in a runtime exception. -
getMarkupSourcingStrategy
Get the markup sourcing strategy for the component. If null,newMarkupSourcingStrategy()
will be called.- Returns:
- Markup sourcing strategy
-
newMarkupSourcingStrategy
IfgetMarkupSourcingStrategy()
returns null, this method will be called. By default it returns null, which means that a default markup strategy will be attached to the component.Please note that markup source strategies are not persisted. Instead they get re-created by calling this method again. That's ok since markup sourcing strategies usually do not maintain a state.
- Returns:
- Markup sourcing strategy
-
internalRenderHead
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT! Print to the web response what ever the component wants to contribute to the head section. Make sure that all attached behaviors are asked as well.NOT intended for overriding by framework clients. Rather, use
renderHead(org.apache.wicket.markup.head.IHeaderResponse)
- Parameters:
container
- The HtmlHeaderContainer
-
replaceWith
Replaces this component with another. The replacing component must have the same component id as this component. This method serves as a shortcut tothis.getParent().replace(replacement)
and provides a better context for errors.Usage:
component = component.replaceWith(replacement);
- Parameters:
replacement
- component to replace this one- Returns:
- the component which replaced this one
- Since:
- 1.2.1
-
sameInnermostModel
- Parameters:
component
- The component to compare with- Returns:
- True if the given component's model is the same as this component's model.
-
sameInnermostModel
- Parameters:
model
- The model to compare with- Returns:
- True if the given component's model is the same as this component's model.
-
setEnabled
Sets whether this component is enabled. Specific components may decide to implement special behavior that uses this property, like web form components that add a disabled='disabled' attribute when enabled is false. If it is not enabled, it will not be allowed to call any listener method on it (e.g. Link.onClick) and the model object will be protected (for the common use cases, not for programmer's misuse)- Parameters:
enabled
- whether this component is enabled- Returns:
- This
-
setEscapeModelStrings
Sets whether model strings should be escaped.- Parameters:
escapeMarkup
- True is model strings should be escaped- Returns:
- This
-
setMarkupIdImpl
Set markup ID, which must be String or Integer- Parameters:
markupId
-
-
setMarkupId
Sets this component's markup id to a user defined value. It is up to the user to ensure this value is unique.The recommended way is to let wicket generate the value automatically, this method is here to serve as an override for that value in cases where a specific id must be used.
If null is passed in the user defined value is cleared and markup id value will fall back on automatically generated value
- Parameters:
markupId
- markup id value or null to clear any previous user defined value- Returns:
- this for chaining
- See Also:
-
setMetaData
Sets the metadata for this component using the given key. If the metadata object is not of the correct type for the metadata key, an IllegalArgumentException will be thrown. For information on creating MetaDataKeys, seeMetaDataKey
.- Specified by:
setMetaData
in interfaceIMetadataContext<Serializable,
Component> - Type Parameters:
M
- The type of the metadata- Parameters:
key
- The singleton key for the metadataobject
- The metadata object- Throws:
IllegalArgumentException
- See Also:
-
setDefaultModel
Sets the given model.WARNING: DO NOT OVERRIDE THIS METHOD UNLESS YOU HAVE A VERY GOOD REASON FOR IT. OVERRIDING THIS MIGHT OPEN UP SECURITY LEAKS AND BREAK BACK-BUTTON SUPPORT.
- Parameters:
model
- The model- Returns:
- This
-
setDefaultModelObject
Sets the backing model object. UnlikegetDefaultModel().setObject(object)
, this method checks authorisation and model comparator, and invokesmodelChanging
andmodelChanged
if the value really changes.- Parameters:
object
- The object to set- Returns:
- This
- Throws:
IllegalStateException
- If the component has neither its own model nor any of its parents usesIComponentInheritedModel
-
setOutputMarkupId
Sets whether or not component will output id attribute into the markup. id attribute will be set to the value returned fromgetMarkupId()
.- Parameters:
output
- True if the component will output the id attribute into markup. Please note that the default behavior is to use the same id as the component. This means that your component must begin with [a-zA-Z] in order to generate a valid markup id according to: http://www.w3.org/TR/html401/types.html#type-name- Returns:
- this for chaining
-
setOutputMarkupPlaceholderTag
Render a placeholder tag when the component is not visible. The tag is of form: <componenttag hidden="" id="markupid"/>. This method will also callsetOutputMarkupId(true)
. This is useful, for example, in ajax situations where the component starts out invisible and then becomes visible through an ajax update. With a placeholder tag already in the markup you do not need to repaint this component's parent, instead you can repaint the component directly. When this method is called with parameterfalse
the outputmarkupid flag is not reverted to false.- Parameters:
outputTag
-- Returns:
- this for chaining
-
setRenderBodyOnly
If false the component's tag will be printed as well as its body (which is default). If true only the body will be printed, but not the component's tag.- Parameters:
renderTag
- If true, the component tag will not be printed- Returns:
- This
-
setResponsePage
Sets the page that will respond to this request- Type Parameters:
C
-- Parameters:
cls
- The response page class- See Also:
-
setResponsePage
public final <C extends IRequestablePage> void setResponsePage(Class<C> cls, PageParameters parameters) Sets the page class and its parameters that will respond to this request- Type Parameters:
C
-- Parameters:
cls
- The response page classparameters
- The parameters for this bookmarkable page.- See Also:
-
setResponsePage
Sets the page that will respond to this request- Parameters:
page
- The response page- See Also:
-
setVersioned
- Parameters:
versioned
- True to turn on versioning for this component, false to turn it off for this component and any children.- Returns:
- This
-
setVisible
Sets whether this component and any children are visible.- Parameters:
visible
- True if this component and any children should be visible- Returns:
- This
-
toString
Gets the string representation of this component. -
toString
- Parameters:
detailed
- True if a detailed string is desired- Returns:
- The string
-
urlFor
Returns a bookmarkable URL that references a given page class using a given set of page parameters. Since the URL which is returned contains all information necessary to instantiate and render the page, it can be stored in a user's browser as a stable bookmark.- Type Parameters:
C
-- Parameters:
pageClass
- Class of pageparameters
- Parameters to page- Returns:
- Bookmarkable URL to page
- See Also:
-
urlForListener
Gets a URL for the listener interface on a behavior (e.g.IRequestListener
onAjaxPagingNavigationBehavior
).- Parameters:
behaviour
- The behavior that the URL should point toparameters
- The parameters that should be rendered into the urls- Returns:
- The URL
-
urlFor
Returns a URL that references the given request target.- Parameters:
requestHandler
- the request target to reference- Returns:
- a URL that references the given request target
- See Also:
-
urlForListener
Gets a URL for thisIRequestListener
.- Parameters:
parameters
- The parameters that should be rendered into the URL- Returns:
- The URL
- See Also:
-
urlFor
Returns a URL that references a shared resource through the provided resource reference.- Parameters:
resourceReference
- The resource referenceparameters
- parameters ornull
if none- Returns:
- The url for the shared resource
- See Also:
-
visitParents
public final <R,C extends MarkupContainer> R visitParents(Class<C> parentClass, IVisitor<C, R> visitor) Traverses all parent components of the given class in this parentClass, calling the visitor's visit method at each one.- Type Parameters:
R
- the type of the result object- Parameters:
parentClass
- Classvisitor
- The visitor to call at each parent of the given type- Returns:
- First non-null value returned by visitor callback
-
visitParents
public final <R,C extends MarkupContainer> R visitParents(Class<C> parentClass, IVisitor<C, R> visitor, IVisitFilter filter) Traverses all parent components of the given class in this parentClass, calling the visitor's visit method at each one.- Type Parameters:
R
- the type of the result object- Parameters:
parentClass
- the class of the parent componentvisitor
- The visitor to call at each parent of the given typefilter
- a filter that adds an additional logic to the condition whether a parent container matches- Returns:
- First non-null value returned by visitor callback
-
warn
Registers a warning feedback message for this component.- Specified by:
warn
in interfaceIFeedbackContributor
- Parameters:
message
- The feedback message
-
addStateChange
TODO WICKET-NG rename to something more useful - like componentChanged(), this method used to be called with a Change object Adds state change to page. -
checkComponentTag
Checks whether the given type has the expected name.- Parameters:
tag
- The tag to checkname
- The expected tag name- Throws:
MarkupException
- Thrown if the tag is not of the right name
-
checkComponentTagAttribute
Checks that a given tag has a required attribute value.- Parameters:
tag
- The tagkey
- The attribute keyvalues
- The required value for the attribute key- Throws:
MarkupException
- Thrown if the tag does not have the required attribute value
-
checkHierarchyChange
Checks whether the hierarchy may be changed at all, and throws an exception if this is not the case.- Parameters:
component
- the component which is about to be added or removed
-
detachModel
Detaches the model for this component if it is detachable. -
exceptionMessage
Suffixes an exception message with useful information about this. component.- Parameters:
message
- The message- Returns:
- The modified message
-
findMarkupStream
Finds the markup stream for this component.- Returns:
- The markup stream for this component. Since a Component cannot have a markup stream, we ask this component's parent to search for it.
-
findPage
If this Component is a Page, returns self. Otherwise, searches for the nearest Page parent in the component hierarchy. If no Page parent can be found,null
is returned.- Returns:
- The Page or
null
if none can be found
-
getBehaviors
Gets the subset of the currently coupledBehavior
s that are of the provided type as an unmodifiable list. Returns an empty list if there are no behaviors coupled to this component.- Type Parameters:
M
- A class derived from Behavior- Parameters:
type
- The type or null for all- Returns:
- The subset of the currently coupled behaviors that are of the provided type as an unmodifiable list
-
getFlag
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!- Parameters:
flag
- The flag to test- Returns:
- True if the flag is set
-
getRequestFlag
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!- Parameters:
flag
- The flag to test- Returns:
- True if the flag is set
-
getInnermostModel
Finds the innermost IModel object for an IModel that might contain nested IModel(s).- Parameters:
model
- The model- Returns:
- The innermost (most nested) model
-
getModelComparator
Gets the component's current model comparator. Implementations can be used for testing the current value of the components model data with the new value that is given.- Returns:
- the value defaultModelComparator
-
getStatelessHint
Returns whether the component can be stateless. Also the component behaviors must be stateless, otherwise the component will be treat as stateful. In order for page to be stateless (and not to be stored in session), all components (and component behaviors) must be stateless.- Returns:
- whether the component can be stateless
-
initModel
Called when a null model is about to be retrieved in order to allow a subclass to provide an initial model.By default this implementation looks components in the parent chain owning a
IComponentInheritedModel
to provide a model for this component viaIComponentInheritedModel.wrapOnInheritance(Component)
.For example a
FormComponent
has the opportunity to instantiate a model on the fly using itsid
and the containingForm
's model, if the form holds aCompoundPropertyModel
.- Returns:
- The model
-
internalOnModelChanged
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.Called anytime a model is changed via setModel or setModelObject.
-
isBehaviorAccepted
Components are allowed to reject behavior modifiers.- Parameters:
behavior
-- Returns:
- False, if the component should not apply this behavior
-
isIgnoreAttributeModifier
If true, all attribute modifiers will be ignored- Returns:
- True, if attribute modifiers are to be ignored
-
onAfterRender
Called immediately after a component and all its children have been rendered, regardless of any exception. -
onBeforeRender
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().onBeforeRender()
call to its children it is strongly recommended that super call is made at the end of the override. -
onComponentTag
Processes the component tag. Overrides of this method most likely should call the super implementation.- Parameters:
tag
- Tag to modify
-
onComponentTagBody
Processes the body.- Parameters:
markupStream
- The markup streamopenTag
- The open tag for the body
-
onDetach
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. -
onRemove
Called to notify the component it is being removed from the component hierarchy Overrides of this method MUST call the super implementation, the most logical place to do this is the last line of the override method. -
onModelChanged
Called anytime a model is changed after the change has occurred -
onModelChanging
Called anytime a model is changed, but before the change actually occurs -
onRender
Implementation that renders this component. -
renderComponentTag
Writes a simple tag out to the response stream. Any components that might be referenced by the tag are ignored. Also undertakes any tag attribute modifications if they have been added to the component.- Parameters:
tag
- The tag to write
-
replaceComponentTagBody
protected final void replaceComponentTagBody(MarkupStream markupStream, ComponentTag tag, CharSequence body) Replaces the body with the given one.- Parameters:
markupStream
- The markup stream to replace the tag body intag
- The tagbody
- The new markup
-
setAuto
- Parameters:
auto
- True to put component into auto-add mode
-
setFlag
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!- Parameters:
flag
- The flag to setset
- True to turn the flag on, false to turn it off
-
setIgnoreAttributeModifier
If true, all attribute modifiers will be ignored- Parameters:
ignore
- If true, all attribute modifiers will be ignored- Returns:
- This
-
wrap
- Type Parameters:
V
- The model type- Parameters:
model
- The model to wrap if need be- Returns:
- The wrapped model
-
get
Gets the component at the given path.- Specified by:
get
in interfaceIRequestableComponent
- Parameters:
path
- Path to component- Returns:
- The component at the path
-
isAuto
- Returns:
- True if this component or any of its parents is in auto-add mode
-
setParent
THIS IS A WICKET INTERNAL API. DO NOT USE IT. Sets the parent of a component. Typically what you really want is parent.add(child). Note that calling setParent() and not parent.add() will connect the child to the parent, but the parent will not know the child. This might not be a problem in some cases, but e.g. child.onDetach() will not be invoked (since the parent doesn't know it is his child).- Parameters:
parent
- The parent container
-
setVisibilityAllowed
Sets whether or not this component is allowed to be visible. This method is meant to be used by components to control visibility of other components. A call tosetVisible(boolean)
will not always have a desired effect because that component may haveisVisible()
overridden. BothsetVisibilityAllowed(boolean)
andisVisibilityAllowed()
arefinal
so their contract is enforced always.- Parameters:
allowed
-- Returns:
this
for chaining
-
isVisibilityAllowed
Gets whether or not visibility is allowed on this component. SeesetVisibilityAllowed(boolean)
for details.- Returns:
- true if this component is allowed to be visible, false otherwise.
-
determineVisibility
Determines whether or not a component should be visible, taking into account all the factors:isVisible()
,isVisibilityAllowed()
,isRenderAllowed()
- Returns:
true
if the component should be visible,false
otherwise
-
isEnabledInHierarchy
Calculates enabled state of the component taking its hierarchy into account. A component is enabled iff it is itself enabled (isEnabled()
andisEnableAllowed()
both returntrue
), and all of its parents are enabled.- Returns:
true
if this component is enabled
-
isRendering
Says if the component is rendering currently.- Returns:
- true if this component is rendering, false otherwise.
-
canCallListener
Checks whether or not anIRequestListener
can be invoked on this component. Usually components deny these invocations if they are either invisible or disabled in hierarchy.WARNING: be careful when overriding this method because it may open security holes - such as allowing a user to click on a link that should be disabled.
Example usecase for overriding: Suppose you are building an component that displays images. The component generates a callback to itself using
IRequestListener
interface and uses this callback to stream image data. If such a component is placed inside a disabledWebMarkupContainer
we still want to allow the invocation of the request listener callback method so that image data can be streamed. Such a component would override this method and return true.- Returns:
- true iff the listener method can be invoked on this component
-
renderHead
Render to the web response whatever the component wants to contribute to the head section.- Specified by:
renderHead
in interfaceIHeaderContributor
- Parameters:
response
- Response object
-
onEvent
Called when an event is sent to this sink- Specified by:
onEvent
in interfaceIEventSink
-
send
Sends an event- Specified by:
send
in interfaceIEventSource
- Type Parameters:
T
- type of payload- Parameters:
sink
- object that will receive the eventtype
- if the object that receives the event needs to broadcast it to others, this is the type of broadcast that should be usedpayload
- event payload
-
remove
Removes behavior from component- Parameters:
behaviors
- behaviors to remove- Returns:
- this (to allow method call chaining)
-
getBehaviorById
Gets the behavior for the specified id- Specified by:
getBehaviorById
in interfaceIRequestableComponent
- Returns:
- behavior or
null
if none
-
getBehaviorId
Gets a stable id for the specified non-temporary behavior. The id remains stable from the point this method is first called for the behavior until the behavior has been removed from the component. This includes from one request to the next, when the component itself is retained for the next request (i.e. is stateful). Note that the bookkeeping required for these stable ids increases the memory footprint of the component.- Specified by:
getBehaviorId
in interfaceIRequestableComponent
- Returns:
- a stable id for the specified behavior
-
add
Adds a behavior modifier to the component.- Parameters:
behaviors
- The behavior modifier(s) to be added- Returns:
- this (to allow method call chaining)
-
getBehaviors
Gets the currently coupledBehavior
s as an unmodifiable list. Returns an empty list rather than null if there are no behaviors coupled to this component.- Returns:
- The currently coupled behaviors as an unmodifiable list
-
canCallListenerAfterExpiry
- Specified by:
canCallListenerAfterExpiry
in interfaceIRequestableComponent
- Returns:
true
if it is save to call anIRequestListener
on this component when the owner page is freshly created after expiration
-
onReAdd
This method is called whenever a component is re-added to the page's component tree, if it had been removed at some earlier time, i.e., if it is already initialized (seeisInitialized()
). This is similar to onInitialize, but only comes after the component has been removed and then added again:- onInitialize is only called the very first time a component is added
- onReAdd is not called the first time, but every time it is re-added after having been removed
-