|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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.
onInitialize()
method is called when a path from this
component to its parent has been established, usually after the component has been added to its
parent.
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).
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.
onDetach()
method is called.
setDefaultModel(IModel model)
and retrieved via
getDefaultModel()
, 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 getDefaultModelObject()
is provided to retrieve the model Object from
its IModel wrapper. A further convenience method,
getDefaultModelObjectAsString()
, 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.
AttributeModifier
s 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()
.
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<T extends Component>
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_CONFIGURED
True when component has been configured, had onConfigure() called |
protected static int |
FLAG_INITIALIZED
True when a component has been initialized, had onInitialize() called |
protected static int |
FLAG_REMOVING_FROM_HIERARCHY
True when a component is being removed from the hierarchy |
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(String id)
Constructor. |
|
Component(String id,
IModel<?> model)
Constructor. |
Method Summary | ||
---|---|---|
Component |
add(IBehavior... behaviors)
Adds a 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. |
|
protected boolean |
callOnBeforeRenderIfNotVisible()
Deprecated. this was only useful for controlling visibility from inside onBeforeRender() , with the addition of onConfigure() this is
now obsolete. |
|
protected void |
checkComponentTag(ComponentTag tag,
String name)
Checks whether the given type has the expected name. |
|
protected void |
checkComponentTagAttribute(ComponentTag tag,
String key,
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. |
|
void |
configure()
Triggers onConfigure() to be invoked on this component if it has not already during
this request. |
|
boolean |
continueToOriginalDestination()
Redirects to any intercept page previously specified by a call to redirectToInterceptPage. |
|
void |
debug(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 |
|
boolean |
determineVisibility()
Determines whether or not a component should be visible, taking into account all the factors: isVisible() , isVisibilityAllowed() , isRenderAllowed() |
|
void |
error(Serializable message)
Registers an error feedback message for this component |
|
protected String |
exceptionMessage(String message)
Prefixes an exception message with useful information about this. |
|
void |
fatal(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. |
|
|
findParent(Class<Z> 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. |
|
List<IBehavior> |
getBehaviors()
Gets the currently coupled IBehavior s as a unmodifiable list. |
|
protected
|
getBehaviors(Class<M> type)
Gets the subset of the currently coupled IBehavior s that are of the provided type as
a unmodifiable list. |
|
List<IBehavior> |
getBehaviorsRawList()
FOR INTERNAL USE ONLY |
|
String |
getClassRelativePath()
|
|
IComponentBorder |
getComponentBorder()
Deprecated. |
|
IConverter |
getConverter()
Deprecated. To be removed. Please use/ override getConverter(Class) instead. |
|
IConverter |
getConverter(Class<?> type)
Gets the converter that should be used by this component. |
|
IModel<?> |
getDefaultModel()
Gets the model. |
|
Object |
getDefaultModelObject()
Gets the backing model object. |
|
String |
getDefaultModelObjectAsString()
Gets a model object as a string. |
|
String |
getDefaultModelObjectAsString(Object modelObject)
Gets a model object as a string. |
|
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. |
|
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). |
|
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. |
|
String |
getMarkupId()
Calls getMarkupId(boolean) with 'true'. |
|
String |
getMarkupId(boolean createIfDoesNotExist)
Retrieves id by which this component is represented within the markup. |
|
Object |
getMarkupIdImpl()
Get the markupId |
|
|
getMetaData(MetaDataKey<M> key)
Gets metadata for this component using the given key. |
|
IModelComparator |
getModelComparator()
Gets the component's current model comparator. |
|
boolean |
getOutputMarkupId()
Gets whether or not component will output id attribute into the markup. |
|
boolean |
getOutputMarkupPlaceholderTag()
Gets whether or not an invisible component will render a placeholder tag. |
|
Page |
getPage()
Gets the page holding this component. |
|
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. |
|
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. |
|
String |
getString(String key)
|
|
String |
getString(String key,
IModel<?> model)
|
|
String |
getString(String key,
IModel<?> model,
String defaultValue)
|
|
String |
getStyle()
Gets the style of this component (see Session ). |
|
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(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. |
|
boolean |
isEnabledInHierarchy()
Calculates enabled state of the component taking its hierarchy into account. |
|
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 |
isVisibilityAllowed()
Gets whether or not visibility is allowed on this component. |
|
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(boolean setRenderingFlag)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
|
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 |
|
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 onConfigure() or onBeforeRender() instead |
|
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag. |
|
protected void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Processes the body. |
|
protected void |
onConfigure()
Called once per request on components before they are about to be rendered. |
|
protected void |
onDetach()
Called to allow a component to detach resources after use. |
|
protected void |
onEndRequest()
Deprecated. use onDetach() instead |
|
protected void |
onInitialize()
This method is meant to be used as an alternative to initialize components. |
|
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 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(MarkupStream markupStream)
Implementation that renders this component. |
|
void |
prepareForRender()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
|
void |
prepareForRender(boolean setRenderingFlag)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
|
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 |
renderPlaceholderTag(ComponentTag tag,
Response response)
Renders a placeholder tag for the component when it is invisible and setOutputMarkupPlaceholderTag(boolean) has been called with true . |
|
protected void |
replaceComponentTagBody(MarkupStream markupStream,
ComponentTag tag,
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)
Deprecated. |
|
Component |
setDefaultModel(IModel<?> model)
Sets the given model. |
|
Component |
setDefaultModelObject(Object object)
Sets the backing model object. |
|
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 |
|
Component |
setMarkupId(String markupId)
Sets this component's markup id to a user defined value. |
|
void |
setMarkupIdImpl(Object markupId)
Set markup ID, which must be String or Integer |
|
protected void |
setMarkupStream(MarkupStream markupStream)
The markup stream will be assigned to the component at the beginning of the component render phase. |
|
|
setMetaData(MetaDataKey<M> key,
M object)
Sets the metadata for this component using the given key. |
|
Component |
setOutputMarkupId(boolean output)
Sets whether or not component will output id attribute into the markup. |
|
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). |
|
|
setResponsePage(Class<C> cls)
Sets the page that will respond to this request |
|
|
setResponsePage(Class<C> 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 |
setVisibilityAllowed(boolean allowed)
Sets whether or not this component is allowed to be visible. |
|
Component |
setVisible(boolean visible)
Sets whether this component and any children are visible. |
|
String |
toString()
Gets the string representation of this component. |
|
String |
toString(boolean detailed)
|
|
|
urlFor(Class<C> pageClass,
PageParameters parameters)
Returns a bookmarkable URL that references a given page class using a given set of page parameters. |
|
CharSequence |
urlFor(IBehavior behaviour,
RequestListenerInterface listener)
Gets a URL for the listener interface on a behavior (e.g. |
|
|
urlFor(IPageMap pageMap,
Class<C> pageClass,
PageParameters parameters)
Returns a bookmarkable URL that references a given page class using a given set of page parameters. |
|
CharSequence |
urlFor(IRequestTarget requestTarget)
Returns a URL that references the given request target. |
|
CharSequence |
urlFor(RequestListenerInterface listener)
Gets a URL for the listener interface (e.g. |
|
CharSequence |
urlFor(ResourceReference resourceReference)
Returns a URL that references a shared resource through the provided resource reference. |
|
Object |
visitParents(Class<?> c,
Component.IVisitor<Component> visitor)
Traverses all parent components of the given class in this container, calling the visitor's visit method at each one. |
|
void |
warn(String message)
Registers a warning feedback message for this component. |
|
protected
|
wrap(IModel<V> 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
protected static final int FLAG_REMOVING_FROM_HIERARCHY
protected static final int FLAG_INITIALIZED
onInitialize()
called
protected static final int FLAG_CONFIGURED
onConfigure()
called
Constructor Detail |
---|
public Component(String id)
id
- The non-null id of this component
WicketRuntimeException
- Thrown if the component has been given a null id.public Component(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... behaviors)
Note: this method is override to enable users to do things like discussed in this thread.
behaviors
- The behavior modifier(s) to be added
public final List<IBehavior> getBehaviorsRawList()
public final void afterRender()
public final void beforeRender()
public final void configure()
onConfigure()
to be invoked on this component if it has not already during
this request.
This method should be invoked before any calls to isVisible()
or
isEnabled()
. 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()); } }
public final boolean continueToOriginalDestination()
redirectToInterceptPage(Page)
public final void debug(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(Serializable message)
message
- The feedback messagepublic final void fatal(String message)
message
- The feedback messagepublic final <Z> Z findParent(Class<Z> c)
Z
- type of parentc
- MarkupContainer class to search for
public final MarkupContainer findParentWithAssociatedMarkup()
public final Application getApplication()
Application
public final List<IBehavior> getBehaviors()
IBehavior
s as a unmodifiable list. Returns an empty list
rather than null if there are no behaviors coupled to this component.
public final String getClassRelativePath()
getPageRelativePath()
@Deprecated public final IComponentBorder getComponentBorder()
@Deprecated public final IConverter getConverter()
getConverter(Class)
instead.
getConverter(Class)
instead.public IConverter getConverter(Class<?> type)
getConverter
in interface IConverterLocator
type
- The type to convert to
public final boolean getEscapeModelStrings()
public final FeedbackMessage getFeedbackMessage()
public String getId()
public final IModel<?> getInnermostModel()
public 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 final Object getMarkupIdImpl()
public String getMarkupId(boolean createIfDoesNotExist)
setMarkupId(String)
, [id attribute defined in
the markup, - not yet working in 1.4] 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.
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 String getMarkupId()
getMarkupId(boolean)
with 'true'.
getMarkupId(boolean)
public final <M extends Serializable> M getMetaData(MetaDataKey<M> key)
M
- The type of the metadata.key
- The key for the data
MetaDataKey
public final IModel<?> getDefaultModel()
public final Object getDefaultModelObject()
public final String getDefaultModelObjectAsString()
Strings.escapeMarkup(String, boolean, boolean)
on the model string returned.
Strings.escapeMarkup(String, boolean, boolean)
,
getEscapeModelStrings()
public final String getDefaultModelObjectAsString(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()
IllegalStateException
- Thrown if component is not yet attached to a Page.public final String getPageRelativePath()
public final MarkupContainer getParent()
public final 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 String getString(String key)
key
- Key of string resource in property file
Localizer
public final String getString(String key, IModel<?> model)
key
- The resource keymodel
- The model
Localizer
public final String getString(String key, IModel<?> model, String defaultValue)
key
- The resource keymodel
- The modeldefaultValue
- A default value if the string cannot be found
Localizer
public final String getStyle()
Session
).
Session
,
Session.getStyle()
public String getVariation()
public final boolean hasBeenRendered()
public final boolean hasErrorMessage()
public final boolean hasFeedbackMessage()
public final void info(String message)
message
- The feedback message@Deprecated public final void internalAttach()
@Deprecated public final void internalDetach()
public final boolean isActionAuthorized(Action action)
action
- The action to authorize
AuthorizationException
- Can be thrown by implementation if action is unauthorized@Deprecated public final boolean isAncestorOf(Component component)
component
- The component to check
public final boolean isEnableAllowed()
public boolean isEnabled()
public final boolean isRenderAllowed()
RENDER
action is allowed on this
component
RENDER
action is allowed, false otherwisepublic final boolean isStateless()
public boolean isVersioned()
public boolean isVisible()
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)
.
public final boolean isVisibleInHierarchy()
public final void markRendering(boolean setRenderingFlag)
setRenderingFlag
- if this is false only the PREPARED_FOR_RENDER flag is removed from component, the
RENDERING flag is not set.prepareForRender(boolean)
public final void modelChanged()
public final void modelChanging()
public void prepareForRender(boolean setRenderingFlag)
Prepares the component and it's children for rendering. On whole page render this method must be called on the page. On AJAX request, this method must be called on updated component.
TODO this method is not part of public api, so rename to internalPrepareForRender
setRenderingFlag
- Whether to set the rendering flag. This must be true if the page is about to be
rendered. However, there are usecases to call this method without an immediate
render (e.g. on stateless listner request target to build the component
hierarchy), in that case setRenderingFlag should be falsepublic final void prepareForRender()
public final void redirectToInterceptPage(Page page)
page
- The sign in pagecontinueToOriginalDestination()
public final void remove()
MarkupContainer#visitChildren(IVisitor)
methods. See https://issues.apache.org/jira/browse/WICKET-3229
.
public Component remove(IBehavior behavior)
behavior
- behavior to remove
public final void render()
For component level re-render (e.g. AJAX) please call renderComponent()
. Though
render() does seem to work, it will fail for panel children.
public final void render(MarkupStream markupStream)
For component level re-render (e.g. AJAX) please call renderComponent(MarkupStream)
.
Though render() does seem to work, it will fail for panel children.
markupStream
- protected void renderPlaceholderTag(ComponentTag tag, Response response)
setOutputMarkupPlaceholderTag(boolean)
has been called with true
.
tag
- component tagresponse
- responsepublic final void renderComponent()
Note: it is not necessary that the page has previously been rendered. But the component must have been added (directly or indirectly) to a container with an associated markup file (Page, Panel or Border).
public final void renderComponent(MarkupStream markupStream)
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.
markupStream
- The markup streampublic final void rendered()
public void renderHead(HtmlHeaderContainer container)
NOT intended for overriding by framework clients. Rather, use
IHeaderContributor.renderHead(org.apache.wicket.markup.html.IHeaderResponse)
container
- The HtmlHeaderContainerpublic void replaceWith(Component replacement)
this.getParent().replace(replacement)
and provides a better context for errors.
replacement
- component to replace this one
TODO 1.5 - this method should return replacement
to facilitate easy
chaning such as component=component.replaceWith(newcomponent);
public final boolean sameInnermostModel(Component component)
component
- The component to compare with
public final boolean sameInnermostModel(IModel<?> model)
model
- The model to compare with
@Deprecated public final Component setComponentBorder(IComponentBorder border)
null
any previous
border will be cleared.
border
- component border to assign, or null
to clear any previous
public final Component setEnabled(boolean enabled)
enabled
- whether this component is enabled
public final Component setEscapeModelStrings(boolean escapeMarkup)
escapeMarkup
- True is model strings should be escaped
public final void setMarkupIdImpl(Object markupId)
markupId
- public Component setMarkupId(String markupId)
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
markupId
- markup id value or null to clear any previous user defined value
getMarkupId()
public final <M> void setMetaData(MetaDataKey<M> key, M object)
MetaDataKey
.
M
- The type of the metadatakey
- The singleton key for the metadataobject
- The metadata object
IllegalArgumentException
MetaDataKey
public Component setDefaultModel(IModel<?> 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.
model
- The model
public final Component setDefaultModelObject(Object object)
getDefaultModel().setObject(object)
, this
method checks authorisation and model comparator, and invokes modelChanging
and
modelChanged
if the value really changes.
object
- The object to set
public final Component setOutputMarkupId(boolean output)
getMarkupId()
.
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
public final Component setOutputMarkupPlaceholderTag(boolean outputTag)
setOutputMarkupId(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 parameter false
the outputmarkupid flag is not
reverted to false.
outputTag
-
public final void setRedirect(boolean redirect)
redirect
- True if the response should be redirected toRequestCycle.setRedirect(boolean)
public final Component setRenderBodyOnly(boolean renderTag)
renderTag
- If true, the component tag will not be printed
public final <C extends Page> void setResponsePage(Class<C> cls)
C
- cls
- The response page classRequestCycle.setResponsePage(Class)
public final <C extends Page> void setResponsePage(Class<C> cls, PageParameters parameters)
C
- cls
- The response page classparameters
- The parameters for this bookmarkable page.RequestCycle.setResponsePage(Class, PageParameters)
public final void setResponsePage(Page page)
page
- The response pageRequestCycle.setResponsePage(Page)
public Component setVersioned(boolean versioned)
versioned
- True to turn on versioning for this component, false to turn it off for this
component and any children.
public final Component setVisible(boolean visible)
visible
- True if this component and any children should be visible
public String toString()
public String toString(boolean detailed)
detailed
- True if a detailed string is desired
public final <C extends Page> CharSequence urlFor(Class<C> pageClass, PageParameters parameters)
C
- pageClass
- Class of pageparameters
- Parameters to page
RequestCycle.urlFor(IPageMap, Class, PageParameters)
public final CharSequence urlFor(IBehavior behaviour, RequestListenerInterface listener)
behaviour
- The behavior that the URL should point tolistener
- The listener interface that the URL should call
public final <C extends Page> CharSequence urlFor(IPageMap pageMap, Class<C> pageClass, PageParameters parameters)
C
- pageMap
- Page map to usepageClass
- Class of pageparameters
- Parameters to page
RequestCycle.urlFor(IPageMap, Class, PageParameters)
public final CharSequence urlFor(IRequestTarget requestTarget)
requestTarget
- the request target to reference
RequestCycle.urlFor(IRequestTarget)
public final CharSequence urlFor(RequestListenerInterface listener)
listener
- The listener interface that the URL should call
public final CharSequence urlFor(ResourceReference resourceReference)
resourceReference
- The resource reference
RequestCycle.urlFor(ResourceReference)
public final Object visitParents(Class<?> c, Component.IVisitor<Component> visitor)
c
- Classvisitor
- The visitor to call at each parent of the given type
public final void warn(String message)
message
- The feedback messageprotected final void addStateChange(Change change)
change
- The changeprotected final void checkComponentTag(ComponentTag tag, String name)
tag
- The tag to checkname
- The expected tag name
MarkupException
- Thrown if the tag is not of the right nameprotected final void checkComponentTagAttribute(ComponentTag tag, String key, String value)
tag
- The tagkey
- The attribute keyvalue
- The required value for the attribute key
MarkupException
- Thrown if the tag does not have the required attribute valueprotected void checkHierarchyChange(Component component)
component
- the component which is about to be added or removedprotected void detachModel()
protected final String exceptionMessage(String message)
message
- The message
protected MarkupStream findMarkupStream()
protected final Page findPage()
protected <M extends IBehavior> List<M> getBehaviors(Class<M> type)
IBehavior
s that are of the provided type as
a unmodifiable list. Returns an empty list rather than null if there are no behaviors coupled
to this component.
M
- A class derived from IBehaviortype
- The type or null for all
protected final boolean getFlag(int flag)
flag
- The flag to test
protected final boolean getFlag(short flag)
flag
- The flag to test
protected final IModel<?> getInnermostModel(IModel<?> model)
model
- The model
public IModelComparator getModelComparator()
protected boolean getStatelessHint()
protected IModel<?> initModel()
protected final void internalOnAttach()
Called when a request begins.
protected final void internalOnDetach()
Called when a request ends.
protected void internalOnModelChanged()
Called anytime a model is changed via setModel or setModelObject.
protected final void markAttached(boolean attached)
attached
- protected final boolean isAttached()
protected boolean isBehaviorAccepted(IBehavior behavior)
behavior
-
protected final boolean isIgnoreAttributeModifier()
protected MarkupStream locateMarkupStream()
protected void onAfterRender()
@Deprecated protected final void onAttach()
If you need to initialize component before it is rendered, either use
onBeforeRender()
or do the initialization lazily (on first demand, such as
LoadableDetachableModel
does.
Also see onInitialize()
for an alternative init method
If you need to get notification when page is taken out of Session (before calling the event
listener), you can use the Page.onPageAttached()
method.
protected void onBeforeRender()
NOTE: If you override this, you *must* call super.onBeforeRender() within
your implementation.
Because this method is responsible for cascading onBeforeRender()
call to its
children it is strongly recommended that super call is made at the end of the override.
callOnBeforeRenderIfNotVisible()
@Deprecated protected boolean callOnBeforeRenderIfNotVisible()
onBeforeRender()
, with the addition of onConfigure()
this is
now obsolete.
onBeforeRender()
@Deprecated protected final void onBeginRequest()
onConfigure()
or onBeforeRender()
instead
protected void onComponentTag(ComponentTag tag)
tag
- Tag to modifyprotected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
markupStream
- The markup streamopenTag
- The open tag for the bodyprotected void onDetach()
protected void onConfigure()
Overrides must call super.onConfigure()
, usually before any other code
NOTE: 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()
and
isEnabled()
? Because those methods are called multiple times even for processing of
a single request. If they contain expensive logic they can slow down the response time of the
entire page. Further, overriding those methods directly on form components may lead to
inconsistent or unexpected state depending on when those methods are called in the form
processing workflow. It is a better practice to push changes to state rather than pull.
NOTE: If component's visibility or another property depends on another component you may call
other.configure()
followed by other.isVisible()
as mentioned in
configure()
javadoc.
NOTE: Why should onBeforeRender()
not be used for this? Because if visibility of a
component is toggled inside onBeforeRender()
another method needs to be overridden
to make sure onBeforeRender()
will be invoked on invisible components:
class MyComponent extends WebComponent { protected void onBeforeRender() { setVisible(Math.rand() > 0.5f); super.onBeforeRender(); } // if this override is forgotten, once invisible component will never become visible protected boolean callOnBeforeRenderIfNotVisible() { return true; } }VS
class MyComponent extends WebComponent { protected void onConfigure() { setVisible(Math.rand() > 0.5f); super.onConfigure(); } }
protected void onInitialize()
Page
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 method
NOTE:The timing of this call is not precise, the contract is that it is called sometime
before onBeforeRender()
.
protected void onRemove()
@Deprecated protected final void onEndRequest()
protected void onModelChanged()
protected void onModelChanging()
protected abstract void onRender(MarkupStream markupStream)
markupStream
- protected final void renderComponentTag(ComponentTag tag)
tag
- The tag to writeprotected final void replaceComponentTagBody(MarkupStream markupStream, ComponentTag tag, CharSequence body)
markupStream
- The markup stream to replace the tag body intag
- The tagbody
- The new markupprotected final void setAuto(boolean auto)
auto
- True to put component into auto-add modeprotected final void setFlag(int flag, boolean set)
flag
- The flag to setset
- True to turn the flag on, false to turn it offprotected final void setFlag(short flag, boolean set)
flag
- The flag to setset
- True to turn the flag on, false to turn it offprotected final Component setIgnoreAttributeModifier(boolean ignore)
ignore
- If true, all attribute modifiers will be ignored
protected void setMarkupStream(MarkupStream markupStream)
markupStream
- The current markup stream which should be applied by the component to render
itselffindMarkupStream()
,
MarkupContainer.getMarkupStream()
protected final <V> IModel<V> wrap(IModel<V> model)
V
- The model typemodel
- The model to wrap if need be
public final Component setVisibilityAllowed(boolean allowed)
setVisible(boolean)
will not always have a desired effect because that component may
have isVisible()
overridden. Both setVisibilityAllowed(boolean)
and
isVisibilityAllowed()
are final
so their contract is enforced always.
allowed
-
this
for chainingpublic final boolean isVisibilityAllowed()
setVisibilityAllowed(boolean)
for details.
public final boolean determineVisibility()
isVisible()
, isVisibilityAllowed()
, isRenderAllowed()
true
if the component should be visible, false
otherwisepublic final boolean isEnabledInHierarchy()
isEnabled()
and isEnableAllowed()
both
return true
), and all of its parents are enabled.
true
if this component is enabled
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |