|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.Component
public abstract class Component
Component serves as the highest level abstract base class for all components.
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.
RequestCycle which is accessible via
getRequestCycle(). The convenience methods getRequest(),
getResponse() and getSession() provide easy access to the
contents of this container.
IFormSubmitListener.onFormSubmitted()
method implemented by the Form class is really a private implementation detail of the Form class
that is not designed to be overridden (although unfortunately, it must be public since all
interface methods in Java must be public). Instead, Form subclasses should override user-oriented
methods such as onValidate(), onSubmit() and onError() (although only the latter two are likely
to be overridden in practice).
onBeginRequest() method is called.
render(), which calls subclass implementation code contained in
onRender(org.apache.wicket.markup.MarkupStream). Once this phase begins, a
Component becomes immutable. Attempts to alter the Component will result in a
WicketRuntimeException.
onEndRequest() method is called.
setModel(IModel model) and
retrieved via getModel(), to render a response in an appropriate markup
language, such as HTML. In addition, form components know how to update their models based on
request information. Since the IModel interface is a wrapper around an actual model object, a
convenience method getModelObject() is provided to retrieve the model Object
from its IModel wrapper. A further convenience method, getModelObjectAsString(),
is provided for the very common operation of converting the wrapped model Object to a String.
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.
getLocalizer().
The convenience methods getString(String key) and
getString(String key, IModel model) wrap the identical methods on the
Application Localizer for easy access in Components.
getStyle(), which is equivalent to getSession().getStyle(). Styles are
intended to give a particular look to a Component or Resource 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.
AttributeModifiers to any
component if you need to programmatically manipulate attributes of the markup tag to which a
Component is attached.
debug(String),
info(String), warn(String),
error(java.io.Serializable) and fatal(String) 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. Any
feedback message for a given Component can be retrieved with getFeedbackMessage().
getPageFactory() method, returning your own implementation of
IPageFactory.
setVersioned(boolean) method. The versioning participation of a given Component
can be retrieved with isVersioned().
| Nested Class Summary | |
|---|---|
class |
Component.ComponentModelChange
Change record of a model. |
protected static class |
Component.EnabledChange
A enabled change operation. |
static interface |
Component.IVisitor
Generic component visitor interface for component traversals. |
protected static class |
Component.VisibilityChange
A visibility change operation. |
| Field Summary | |
|---|---|
static Action |
ENABLE
Action used with IAuthorizationStrategy to determine whether a component is allowed to be enabled. |
protected static int |
FLAG_RESERVED1
Reserved subclass-definable flag bit |
protected static int |
FLAG_RESERVED2
Reserved subclass-definable flag bit |
protected static int |
FLAG_RESERVED3
Reserved subclass-definable flag bit |
protected static int |
FLAG_RESERVED4
Reserved subclass-definable flag bit |
protected static int |
FLAG_RESERVED5
Reserved subclass-definable flag bit |
protected static int |
FLAG_RESERVED6
Reserved subclass-definable flag bit |
protected static int |
FLAG_RESERVED7
Reserved subclass-definable flag bit |
protected static int |
FLAG_RESERVED8
Reserved subclass-definable flag bit |
static char |
PATH_SEPARATOR
Separator for component paths |
static Action |
RENDER
Action used with IAuthorizationStrategy to determine whether a component and its children are allowed to be rendered. |
| Constructor Summary | |
|---|---|
Component(java.lang.String id)
Constructor. |
|
Component(java.lang.String id,
IModel model)
Constructor. |
|
| Method Summary | |
|---|---|
Component |
add(IBehavior behavior)
Adds an behavior modifier to the component. |
protected void |
addStateChange(Change change)
Adds state change to page. |
void |
afterRender()
Called on very component after the page is rendered. |
void |
beforeRender()
Called for every component when the page is getting to be rendered. it will call onBeforeRender for this component and all the child components |
protected boolean |
callOnBeforeRenderIfNotVisible()
Override this method if you want onBeforeRender to be called even when your component is not visible. default this returns false. |
protected void |
checkComponentTag(ComponentTag tag,
java.lang.String name)
Checks whether the given type has the expected name. |
protected void |
checkComponentTagAttribute(ComponentTag tag,
java.lang.String key,
java.lang.String value)
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. |
boolean |
continueToOriginalDestination()
Redirects to any intercept page previously specified by a call to redirectToInterceptPage. |
void |
debug(java.lang.String message)
Registers a debug feedback message for this component |
void |
detach()
Detaches the component. |
void |
detachBehaviors()
THIS IS WICKET INTERNAL ONLY. |
protected void |
detachModel()
Detaches the model for this component if it is detachable. |
void |
detachModels()
Detaches all models |
void |
error(java.io.Serializable message)
Registers an error feedback message for this component |
protected java.lang.String |
exceptionMessage(java.lang.String message)
Prefixes an exception message with useful information about this. component. |
void |
fatal(java.lang.String message)
Registers an fatal error feedback message for this component |
protected MarkupStream |
findMarkupStream()
Finds the markup stream for this component. |
protected Page |
findPage()
If this Component is a Page, returns self. |
MarkupContainer |
findParent(java.lang.Class c)
Finds the first container parent of this component of the given class. |
MarkupContainer |
findParentWithAssociatedMarkup()
|
Application |
getApplication()
Gets interface to application that this component is a part of. |
java.util.List |
getBehaviors()
Gets the currently coupled IBehaviors as a unmodifiable list. |
protected java.util.List |
getBehaviors(java.lang.Class type)
Gets the subset of the currently coupled IBehaviors that are of the provided type as
a unmodifiable list or null if there are no behaviors attached. |
java.lang.String |
getClassRelativePath()
|
IComponentBorder |
getComponentBorder()
|
IConverter |
getConverter()
Deprecated. To be removed. Please use/ override getConverter(Class) instead. |
IConverter |
getConverter(java.lang.Class type)
Gets the converter that should be used by this component. |
boolean |
getEscapeModelStrings()
Gets whether model strings should be escaped. |
FeedbackMessage |
getFeedbackMessage()
|
protected boolean |
getFlag(int flag)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected boolean |
getFlag(short flag)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
java.lang.String |
getId()
Gets the id of this component. |
IModel |
getInnermostModel()
|
protected IModel |
getInnermostModel(IModel model)
Finds the innermost IModel object for an IModel that might contain nested IModel(s). |
java.util.Locale |
getLocale()
Gets the locale for this component. |
Localizer |
getLocalizer()
Convenience method to provide easy access to the localizer object within any component. |
ValueMap |
getMarkupAttributes()
THIS IS WICKET INTERNAL ONLY. |
java.lang.String |
getMarkupId()
Retrieves id by which this component is represented within the markup. |
java.lang.String |
getMarkupId(boolean createIfDoesNotExist)
Retrieves id by which this component is represented within the markup. |
java.io.Serializable |
getMetaData(MetaDataKey key)
Gets metadata for this component using the given key. |
IModel |
getModel()
Gets the model. |
protected IModelComparator |
getModelComparator()
Gets the value defaultModelComparator. |
java.lang.Object |
getModelObject()
Gets the backing model object; this is shorthand for getModel().getObject(). |
java.lang.String |
getModelObjectAsString()
Gets a model object as a string. |
java.lang.String |
getModelObjectAsString(java.lang.Object modelObject)
Gets a model object as a string. |
boolean |
getOutputMarkupId()
Gets whether or not component will output id attribute into the markup. id attribute will be set to the value returned from getMarkupId(). |
boolean |
getOutputMarkupPlaceholderTag()
Gets whether or not an invisible component will render a placeholder tag. |
Page |
getPage()
Gets the page holding this component. |
IPageFactory |
getPageFactory()
|
java.lang.String |
getPageRelativePath()
Gets the path to this component relative to the page it is in. |
MarkupContainer |
getParent()
Gets any parent container, or null if there is none. |
java.lang.String |
getPath()
Gets this component's path. |
boolean |
getRenderBodyOnly()
If false the component's tag will be printed as well as its body (which is default). |
Request |
getRequest()
|
RequestCycle |
getRequestCycle()
Gets the active request cycle for this component |
Response |
getResponse()
|
Session |
getSession()
Gets the current Session object. |
long |
getSizeInBytes()
|
protected boolean |
getStatelessHint()
Returns whether the component can be stateless. |
java.lang.String |
getString(java.lang.String key)
|
java.lang.String |
getString(java.lang.String key,
IModel model)
|
java.lang.String |
getString(java.lang.String key,
IModel model,
java.lang.String defaultValue)
|
java.lang.String |
getStyle()
Gets the style of this component (see Session). |
java.lang.String |
getVariation()
Gets the variation string of this component that will be used to look up markup for this component. |
boolean |
hasBeenRendered()
Gets whether this component was rendered at least once. |
boolean |
hasErrorMessage()
|
boolean |
hasFeedbackMessage()
|
void |
info(java.lang.String message)
Registers an informational feedback message for this component |
protected IModel |
initModel()
Called when a null model is about to be retrieved in order to allow a subclass to provide an initial model. |
void |
internalAttach()
Deprecated. |
void |
internalDetach()
Deprecated. |
protected void |
internalOnAttach()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
internalOnDetach()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
internalOnModelChanged()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
boolean |
isActionAuthorized(Action action)
Authorizes an action for a component. |
boolean |
isAncestorOf(Component component)
Deprecated. use getParent().contains(component, false) |
protected boolean |
isAttached()
|
protected boolean |
isBehaviorAccepted(IBehavior behavior)
Components are allowed to reject behavior modifiers. |
boolean |
isEnableAllowed()
|
boolean |
isEnabled()
Gets whether this component is enabled. |
protected boolean |
isIgnoreAttributeModifier()
If true, all attribute modifiers will be ignored |
boolean |
isRenderAllowed()
Checks the security strategy if the RENDER action is allowed on this
component |
boolean |
isStateless()
Returns if the component is stateless or not. |
boolean |
isVersioned()
|
boolean |
isVisible()
Gets whether this component and any children are visible. |
boolean |
isVisibleInHierarchy()
Checks if the component itself and all its parents are visible. |
protected MarkupStream |
locateMarkupStream()
|
protected void |
markAttached(boolean attached)
Convenience method that sets the attached flags. |
void |
markRendering()
Sets the RENDERING flag on component and it's children. |
void |
modelChanged()
Called to indicate that the model content for this component has been changed |
void |
modelChanging()
Called to indicate that the model content for this component is about to change |
Page |
newPage(java.lang.Class c)
Creates a new page using the component's page factory |
Page |
newPage(java.lang.Class c,
PageParameters parameters)
Creates a new page using the component's page factory |
protected void |
onAfterRender()
Called just after a component is rendered. |
protected void |
onAttach()
Deprecated. |
protected void |
onBeforeRender()
Called just before a component is rendered. |
protected void |
onBeginRequest()
Deprecated. use onAttach() instead |
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag. |
protected void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Processes the body. |
protected void |
onDetach()
Called to allow a component to detach resources after use. |
protected void |
onEndRequest()
Deprecated. use onDetach() instead |
protected void |
onModelChanged()
Called anytime a model is changed after the change has occurred |
protected void |
onModelChanging()
Called anytime a model is changed, but before the change actually occurs |
protected abstract void |
onRender(MarkupStream markupStream)
Implementation that renders this component. |
void |
prepareForRender()
Prepares the component and it's children for rendering. |
void |
redirectToInterceptPage(Page page)
Redirects browser to an intermediate page such as a sign-in page. |
void |
remove()
Removes this component from its parent. |
Component |
remove(IBehavior behavior)
Removes behavior from component |
void |
render()
Performs a render of this component as part of a Page level render process. |
void |
render(MarkupStream markupStream)
Performs a render of this component as part of a Page level render process. |
void |
renderComponent()
Page.renderPage() is used to render a whole page. |
void |
renderComponent(MarkupStream markupStream)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
renderComponentTag(ComponentTag tag)
Writes a simple tag out to the response stream. |
void |
rendered()
Called to indicate that a component has been rendered. |
void |
renderHead(HtmlHeaderContainer container)
Print to the web response what ever the component wants to contribute to the head section. |
protected void |
replaceComponentTagBody(MarkupStream markupStream,
ComponentTag tag,
java.lang.CharSequence body)
Replaces the body with the given one. |
void |
replaceWith(Component replacement)
Replaces this component with another. |
boolean |
sameInnermostModel(Component component)
|
boolean |
sameInnermostModel(IModel model)
|
protected void |
setAuto(boolean auto)
|
Component |
setComponentBorder(IComponentBorder border)
Assigns a component border to this component. |
Component |
setEnabled(boolean enabled)
Sets whether this component is enabled. |
Component |
setEscapeModelStrings(boolean escapeMarkup)
Sets whether model strings should be escaped. |
protected void |
setFlag(int flag,
boolean set)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
setFlag(short flag,
boolean set)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected Component |
setIgnoreAttributeModifier(boolean ignore)
If true, all attribute modifiers will be ignored |
void |
setMarkupId(java.lang.String markupId)
Sets this component's markup id to a user defined value. |
protected void |
setMarkupStream(MarkupStream markupStream)
The markup stream will be assigned to the component at the beginning of the component render phase. |
void |
setMetaData(MetaDataKey key,
java.io.Serializable object)
Sets the metadata for this component using the given key. |
Component |
setModel(IModel model)
Sets the given model. |
Component |
setModelObject(java.lang.Object object)
Sets the backing model object; shorthand for getModel().setObject(object). |
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 from getMarkupId(). |
Component |
setOutputMarkupPlaceholderTag(boolean outputTag)
Render a placeholder tag when the component is not visible. |
void |
setRedirect(boolean redirect)
|
Component |
setRenderBodyOnly(boolean renderTag)
If false the component's tag will be printed as well as its body (which is default). |
void |
setResponsePage(java.lang.Class cls)
Sets the page that will respond to this request |
void |
setResponsePage(java.lang.Class cls,
PageParameters parameters)
Sets the page class and its parameters that will respond to this request |
void |
setResponsePage(Page page)
Sets the page that will respond to this request |
Component |
setVersioned(boolean versioned)
|
Component |
setVisible(boolean visible)
Sets whether this component and any children are visible. |
java.lang.String |
toString()
Gets the string representation of this component. |
java.lang.String |
toString(boolean detailed)
|
java.lang.CharSequence |
urlFor(java.lang.Class pageClass,
PageParameters parameters)
Returns a bookmarkable URL that references a given page class using a given set of page parameters. |
java.lang.CharSequence |
urlFor(IBehavior behaviour,
RequestListenerInterface listener)
Gets a URL for the listener interface on a behavior (e.g. |
java.lang.CharSequence |
urlFor(IPageMap pageMap,
java.lang.Class pageClass,
PageParameters parameters)
Returns a bookmarkable URL that references a given page class using a given set of page parameters. |
java.lang.CharSequence |
urlFor(IRequestTarget requestTarget)
Returns a URL that references the given request target. |
java.lang.CharSequence |
urlFor(RequestListenerInterface listener)
Gets a URL for the listener interface (e.g. |
java.lang.CharSequence |
urlFor(ResourceReference resourceReference)
Returns a URL that references a shared resource through the provided resource reference. |
java.lang.Object |
visitParents(java.lang.Class c,
Component.IVisitor visitor)
Traverses all parent components of the given class in this container, calling the visitor's visit method at each one. |
void |
warn(java.lang.String message)
Registers a warning feedback message for this component. |
protected IModel |
wrap(IModel model)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Action ENABLE
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.
public static final char PATH_SEPARATOR
public static final Action RENDER
There are two uses for this method:
AuthorizationException, which will then
be handled further by the framework.
protected static final int FLAG_RESERVED1
protected static final int FLAG_RESERVED2
protected static final int FLAG_RESERVED3
protected static final int FLAG_RESERVED4
protected static final int FLAG_RESERVED5
protected static final int FLAG_RESERVED6
protected static final int FLAG_RESERVED7
protected static final int FLAG_RESERVED8
| Constructor Detail |
|---|
public Component(java.lang.String id)
id - The non-null id of this component
WicketRuntimeException - Thrown if the component has been given a null id.
public Component(java.lang.String id,
IModel model)
id - The non-null id of this componentmodel - The component's model
WicketRuntimeException - Thrown if the component has been given a null id.| Method Detail |
|---|
public Component add(IBehavior behavior)
Note: this method is override to enable users to do things like discussed in this thread.
behavior - The behavior modifier to be added
public final void afterRender()
public final void beforeRender()
public final boolean continueToOriginalDestination()
redirectToInterceptPage(Page)public final void debug(java.lang.String message)
message - The feedback messagepublic final void detach()
public final void detachBehaviors()
AjaxRequestTarget to be able to cleanup
component's behaviors after header contribution has been done (which is separated from
component render).
public void detachModels()
public final void error(java.io.Serializable message)
message - The feedback messagepublic final void fatal(java.lang.String message)
message - The feedback messagepublic final MarkupContainer findParent(java.lang.Class c)
c - MarkupContainer class to search for
public final MarkupContainer findParentWithAssociatedMarkup()
public final Application getApplication()
Applicationpublic final java.util.List getBehaviors()
IBehaviors as a unmodifiable list. Returns an empty list
rather than null if there are no behaviors coupled to this component.
public final java.lang.String getClassRelativePath()
getPageRelativePath()public final IComponentBorder getComponentBorder()
public final IConverter getConverter()
getConverter(Class) instead.
getConverter(Class) instead.public IConverter getConverter(java.lang.Class type)
getConverter in interface IConverterLocatortype - The type to convert to
public final boolean getEscapeModelStrings()
public final FeedbackMessage getFeedbackMessage()
public java.lang.String getId()
public final IModel getInnermostModel()
public java.util.Locale getLocale()
Session.getLocale()public final Localizer getLocalizer()
public final ValueMap getMarkupAttributes()
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).
public java.lang.String getMarkupId(boolean createIfDoesNotExist)
setMarkupId(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 that will be unique in the page. This is the
preferred way as there is no chance of id collision.
Note: This method should only be called after the component or its parent have been added to the page.
createIfDoesNotExist - When there is no existing markup id, determines whether it should be generated or
whether null should be returned.
public java.lang.String getMarkupId()
setMarkupId(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.
Note: This method should only be called after the component or its parent have been added to the page.
public final java.io.Serializable getMetaData(MetaDataKey key)
key - The key for the data
MetaDataKeypublic final IModel getModel()
public final java.lang.Object getModelObject()
public final java.lang.String getModelObjectAsString()
Strings.escapeMarkup(String, boolean, boolean) on the model string returned.
Strings.escapeMarkup(String, boolean, boolean),
getEscapeModelStrings()public final java.lang.String getModelObjectAsString(java.lang.Object modelObject)
Strings.escapeMarkup(String, boolean, boolean) on the model string returned.
modelObject - Model object to convert to string
Strings.escapeMarkup(String, boolean, boolean),
getEscapeModelStrings()public final boolean getOutputMarkupId()
getMarkupId().
public final boolean getOutputMarkupPlaceholderTag()
public final Page getPage()
java.lang.IllegalStateException - Thrown if component is not yet attached to a Page.public final IPageFactory getPageFactory()
public final java.lang.String getPageRelativePath()
public final MarkupContainer getParent()
public final java.lang.String getPath()
public final boolean getRenderBodyOnly()
public final Request getRequest()
public final RequestCycle getRequestCycle()
public final Response getResponse()
public Session getSession()
public long getSizeInBytes()
public final java.lang.String getString(java.lang.String key)
key - Key of string resource in property file
Localizer
public final java.lang.String getString(java.lang.String key,
IModel model)
key - The resource keymodel - The model
Localizer