Class Label
- java.lang.Object
-
- org.apache.wicket.Component
-
- org.apache.wicket.markup.html.WebComponent
-
- org.apache.wicket.markup.html.basic.Label
-
- All Implemented Interfaces:
Serializable
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IMetadataContext<Serializable,Component>
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
- Direct Known Subclasses:
DataTable.Caption
,NavigatorLabel
,SmartLinkLabel
public class Label extends WebComponent
A Label component replaces its body with the String version of its model object returned by getModelObjectAsString().Exactly what is displayed as the body, depends on the model. The simplest case is a Label with a static String model, which can be constructed like this:
add(new Label("myLabel", "the string to display"))
A Label with a dynamic model can be created like this:add(new Label("myLabel", new PropertyModel(person, "name"));
In this case, the Label component will replace the body of the tag it is attached to with the 'name' property of the given Person object, where Person might look like:public class Person { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
- Author:
- Jonathan Locke
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
onComponentTag(ComponentTag tag)
Processes the component tag.void
onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
Processes the body.-
Methods inherited from class org.apache.wicket.markup.html.WebComponent
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession, onRender
-
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, get, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalInitialize, internalOnModelChanged, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onBeforeRender, onConfigure, onDetach, onEvent, onInitialize, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModel, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, toString, toString, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
-
-
-
-
Constructor Detail
-
Label
public Label(String id, Serializable label)
Convenience constructor. Same as Label(String, Model.of(Serializable))- Parameters:
id
- See Componentlabel
- The label text or object, converted to a string via theIConverter
.- See Also:
Component(String, IModel)
-
Label
public Label(String id, IModel<?> model)
- Parameters:
id
-model
-- See Also:
Component(String, IModel)
-
-
Method Detail
-
onComponentTagBody
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
Processes the body.- Overrides:
onComponentTagBody
in classComponent
- Parameters:
markupStream
- The markup streamopenTag
- The open tag for the body
-
onComponentTag
protected void onComponentTag(ComponentTag tag)
Processes the component tag. Overrides of this method most likely should call the super implementation.- Overrides:
onComponentTag
in classComponent
- Parameters:
tag
- Tag to modify
-
-