|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectwicket.Component
Component serves as the highest level abstract base class for all components.
isAncestorOf(Component)method returns
true if this Component is an ancestor of the given Component.
onSessionAttach()method.
RequestCyclewhich 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(). 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 be 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(String)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. |
static interface |
Component.IVisitor
Generic component visitor interface for component traversals. |
protected class |
Component.VisibilityChange
A visibility change operation. |
| Field Summary | |
protected static short |
FLAG_RESERVED1
Reserved subclass-definable flag bit |
protected static short |
FLAG_RESERVED2
Reserved subclass-definable flag bit |
protected static short |
FLAG_RESERVED3
Reserved subclass-definable flag bit |
protected static short |
FLAG_RESERVED4
Reserved subclass-definable flag bit |
| Constructor Summary | |
Component(java.lang.String id)
Constructor. |
|
Component(java.lang.String id,
IModel model)
Constructor. |
|
| Method Summary | |
Component |
add(AttributeModifier modifier)
Adds an attribute modifier to the component. |
protected void |
addStateChange(Change change)
Adds state change to page. |
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. |
void |
debug(java.lang.String message)
Registers a debug message for this component |
protected void |
detachModel()
Detaches the model for this component if it is detachable. |
void |
error(java.lang.String message)
Registers an error message for this component |
protected java.lang.String |
exceptionMessage(java.lang.String message)
Prefixes an exception message with useful information about this. |
void |
fatal(java.lang.String message)
Registers an fatal error 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. |
ApplicationPages |
getApplicationPages()
Gets the application pages from the application that this component belongs to. |
ApplicationSettings |
getApplicationSettings()
Gets the application settings from the application that this component belongs to. |
java.lang.String |
getClassRelativePath()
|
IConverter |
getConverter()
Gets the converter that should be used by this component. |
boolean |
getEscapeModelStrings()
Gets whether model strings should be escaped. |
FeedbackMessage |
getFeedbackMessage()
|
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. |
java.util.Locale |
getLocale()
Gets the locale for the session holding this component. |
Localizer |
getLocalizer()
Convenience method to provide easy access to the localizer object within any component. |
IModel |
getModel()
Gets the model. |
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. |
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 the components' path. |
protected 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 |
Resource |
getResource()
|
Response |
getResponse()
|
Session |
getSession()
Gets the current session object. |
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). |
boolean |
hasErrorMessage()
|
boolean |
hasFeedbackMessage()
|
void |
info(java.lang.String message)
Registers a info 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. |
protected void |
internalBeginRequest()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
internalEndRequest()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
internalOnBeginRequest()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
internalOnEndRequest()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
internalOnModelChanged()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
protected void |
internalOnModelChanging()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
boolean |
isAncestorOf(Component component)
Returns true if this component is an ancestor of the given component |
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. |
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 |
onBeginRequest()
Called when a request begins. |
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag. |
protected void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Processes the body. |
protected void |
onEndRequest()
Called when a request ends. |
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()
Implementation that renders this component. |
protected void |
onSessionAttach()
Called when this component is deserialized as part of session replication |
protected void |
redirectTo(Page page)
Redirects browser to the given page. |
void |
remove()
Removes this component from its parent. |
void |
render()
Performs a render of this component. |
protected void |
renderComponent(MarkupStream markupStream)
Renders the component at the current position in the given markup stream. |
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. |
protected void |
replaceComponentTagBody(MarkupStream markupStream,
ComponentTag tag,
java.lang.String body)
Replaces the body with the given one. |
boolean |
sameRootModel(Component component)
|
boolean |
sameRootModel(IModel model)
|
protected void |
setFlag(short flag,
boolean set)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. |
void |
setModel(IModel model)
Sets the given model. |
void |
setModelObject(java.lang.Object object)
Sets the backing model object; shorthand for getModel().setObject(object). |
void |
setRedirect(boolean redirect)
|
void |
setRenderBodyOnly(boolean renderTag)
If false the component's tag will be printed as well as its body (which is default). |
void |
setResponsePage(Page page)
Sets the page that will respond to this request |
Component |
setShouldEscapeModelStrings(boolean escapeMarkup)
Sets whether model strings should be escaped. |
void |
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.String |
urlFor(java.lang.Class listenerInterface)
|
protected java.lang.Object |
visitParents(java.lang.Class c,
Component.IVisitor visitor)
Visits the parents of this component. |
void |
warn(java.lang.String message)
Registers a warning message for this component. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected static final short FLAG_RESERVED1
protected static final short FLAG_RESERVED2
protected static final short FLAG_RESERVED3
protected static final short FLAG_RESERVED4
| 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 final Component add(AttributeModifier modifier)
modifier - The attribute modifier to be added
public final void debug(java.lang.String message)
message - The messagepublic final void error(java.lang.String message)
message - The messagepublic final void fatal(java.lang.String message)
message - The messagepublic final MarkupContainer findParent(java.lang.Class c)
c - MarkupContainer class to search for
public final MarkupContainer findParentWithAssociatedMarkup()
public final Application getApplication()
Applicationpublic final ApplicationPages getApplicationPages()
ApplicationPagespublic final ApplicationSettings getApplicationSettings()
ApplicationSettingspublic final java.lang.String getClassRelativePath()
getPageRelativePath()public IConverter getConverter()
public final boolean getEscapeModelStrings()
public final FeedbackMessage getFeedbackMessage()
public final java.lang.String getId()
public final java.util.Locale getLocale()
getSession()public final Localizer getLocalizer()
public IModel getModel()
public final java.lang.Object getModelObject()
public final java.lang.String getModelObjectAsString()
public final Page getPage()
public final IPageFactory getPageFactory()
public final java.lang.String getPageRelativePath()
public final MarkupContainer getParent()
public final java.lang.String getPath()
public final Request getRequest()
public final RequestCycle getRequestCycle()
public final Resource getResource()
public final Response getResponse()
public final Session getSession()
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
public final java.lang.String getString(java.lang.String key,
IModel model,
java.lang.String defaultValue)
key - The resource keymodel - The modeldefaultValue - A default value if the string cannot be found
Localizerpublic final java.lang.String getStyle()
Session).
Session,
Session.getStyle()public final boolean hasErrorMessage()
public final boolean hasFeedbackMessage()
public final void info(java.lang.String message)
message - The messagepublic final boolean isAncestorOf(Component component)
component - The component to check
public boolean isVersioned()
public final boolean isVisibleInHierarchy()
public boolean isVisible()
public final void modelChanged()
public final void modelChanging()
public final Page newPage(java.lang.Class c)
c - The class of page to create
public final Page newPage(java.lang.Class c, PageParameters parameters)
c - The class of page to createparameters - Any parameters to pass to the constructor
public final void remove()
public final void render()
public final void rendered()
public final boolean sameRootModel(Component component)
component - The component to compare with
public final boolean sameRootModel(IModel model)
model - The model to compare with
public void setModel(IModel model)
model - the modelpublic final void setModelObject(java.lang.Object object)
object - The object to setpublic final void setRedirect(boolean redirect)
redirect - True if the response should be redirected toRequestCycle.setRedirect(boolean)public final void setRenderBodyOnly(boolean renderTag)
renderTag - If true, the component tag will not be printedprotected final boolean getRenderBodyOnly()
public final void setResponsePage(Page page)
page - The response pageRequestCycle.setResponsePage(Page)public final Component setShouldEscapeModelStrings(boolean escapeMarkup)
escapeMarkup - True is model strings should be escaped
public void 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 java.lang.String toString()
public java.lang.String toString(boolean detailed)
detailed - True if a detailed string is desired
public final java.lang.String urlFor(java.lang.Class listenerInterface)
listenerInterface - The listener interface that the URL should call
Page.urlFor(Component, Class)public final void warn(java.lang.String message)
message - The messageprotected final void addStateChange(Change change)
change - The changeprotected final void checkComponentTag(ComponentTag tag, java.lang.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, java.lang.String key, java.lang.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 detachModel()
protected final java.lang.String exceptionMessage(java.lang.String message)
message - The message
protected MarkupStream findMarkupStream()
protected final Page findPage()
protected final boolean getFlag(short flag)
flag - The flag to test
protected IModel initModel()
protected void internalBeginRequest()
protected void internalEndRequest()
protected void internalOnBeginRequest()
protected void internalOnEndRequest()
protected void internalOnModelChanged()
protected void internalOnModelChanging()
protected void onBeginRequest()
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 onEndRequest()
protected void onModelChanged()
protected void onModelChanging()
protected abstract void onRender()
protected void onSessionAttach()
protected void redirectTo(Page page)
page - The page to redirect toprotected final void renderComponent(MarkupStream markupStream)
markupStream - The markup streamprotected final void renderComponentTag(ComponentTag tag)
tag - The tag to writeprotected final void replaceComponentTagBody(MarkupStream markupStream, ComponentTag tag, java.lang.String body)
markupStream - The markup stream to replace the tag body intag - The tagbody - The new markup
protected final void setFlag(short flag,
boolean set)
flag - The flag to setset - True to turn the flag on, false to turn it off
protected final java.lang.Object visitParents(java.lang.Class c,
Component.IVisitor visitor)
c - Classvisitor - The visitor to call at each parent of the given type
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||