Class DateLabel
- java.lang.Object
-
- org.apache.wicket.Component
-
- org.apache.wicket.markup.html.WebComponent
-
- org.apache.wicket.markup.html.basic.Label
-
- org.wicketstuff.datetime.markup.html.basic.DateLabel
-
- All Implemented Interfaces:
Serializable
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IGenericComponent<Date,DateLabel>
,IMetadataContext<Serializable,Component>
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
public class DateLabel extends Label implements IGenericComponent<Date,DateLabel>
A label that is mapped to ajava.util.Date
object and that uses Joda time to format values.You can provide a date pattern in two of the constructors. When not provided,
DateTimeFormat.shortDate()
will be used.A special option is applyTimeZoneDifference which is an option that says whether to correct for the difference between the client's time zone and server's time zone. This is true by default.
- Author:
- eelcohillenius
- See Also:
DateTime
,DateTimeFormat
,DateTimeZone
, 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
-
-
Constructor Summary
Constructors Constructor Description DateLabel(String id, IModel<Date> model, DateConverter converter)
Construct with a converter.DateLabel(String id, DateConverter converter)
Construct with a converter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IConverter<?>
createConverter(Class<?> type)
Returns the specialized converter.static DateLabel
forDatePattern(String id, String datePattern)
Creates a new DateLabel defaulting to using a short date patternstatic DateLabel
forDatePattern(String id, IModel<Date> model, String datePattern)
Creates a new DateLabel defaulting to using a short date patternstatic DateLabel
forDateStyle(String id, String dateStyle)
Creates a new DateLabel defaulting to using a short date patternstatic DateLabel
forDateStyle(String id, IModel<Date> model, String dateStyle)
Creates a new DateLabel defaulting to using a short date patternstatic DateLabel
forShortStyle(String id)
Creates a new DateLabel defaulting to using a short date patternstatic DateLabel
forShortStyle(String id, IModel<Date> model)
Creates a new DateLabel defaulting to using a short date patternString
getAfter()
String
getBefore()
void
onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
void
setAfter(String after)
void
setBefore(String before)
static DateLabel
withConverter(String id, IModel<Date> model, DateConverter converter)
Creates a new DateLabel using the provided converter.static DateLabel
withConverter(String id, DateConverter converter)
Creates a new DateLabel using the provided converter.-
Methods inherited from class org.apache.wicket.markup.html.basic.Label
onComponentTag
-
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, 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.IGenericComponent
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModel, setDefaultModelObject, setModel, setModelObject
-
-
-
-
Constructor Detail
-
DateLabel
public DateLabel(String id, DateConverter converter)
Construct with a converter.- Parameters:
id
- The component idconverter
- The converter to use
-
DateLabel
public DateLabel(String id, IModel<Date> model, DateConverter converter)
Construct with a converter.- Parameters:
id
- The component idmodel
- The modelconverter
- The converter to use
-
-
Method Detail
-
forDatePattern
public static DateLabel forDatePattern(String id, IModel<Date> model, String datePattern)
Creates a new DateLabel defaulting to using a short date pattern- Parameters:
id
- The id of the text fieldmodel
- The modeldatePattern
- The pattern to use. Must be not null. SeeSimpleDateFormat
for available patterns.- Returns:
- new instance
- See Also:
TextField
-
forDatePattern
public static DateLabel forDatePattern(String id, String datePattern)
Creates a new DateLabel defaulting to using a short date pattern- Parameters:
id
- The id of the text fielddatePattern
- The pattern to use. Must be not null. SeeSimpleDateFormat
for available patterns.- Returns:
- new instance
- See Also:
TextField
-
forDateStyle
public static DateLabel forDateStyle(String id, IModel<Date> model, String dateStyle)
Creates a new DateLabel defaulting to using a short date pattern- Parameters:
id
- The id of the text fieldmodel
- The modeldateStyle
- style to use in case no pattern is provided. Must be two characters from the set {"S", "M", "L", "F", "-"}. Must be not null. SeeDateTimeFormat.forStyle(String)
for options.- Returns:
- new instance
- See Also:
TextField
-
forDateStyle
public static DateLabel forDateStyle(String id, String dateStyle)
Creates a new DateLabel defaulting to using a short date pattern- Parameters:
id
- The id of the text fielddateStyle
- style to use in case no pattern is provided. Must be two characters from the set {"S", "M", "L", "F", "-"}. Must be not null. SeeDateTimeFormat.forStyle(String)
for options.- Returns:
- new instance
- See Also:
TextField
-
forShortStyle
public static DateLabel forShortStyle(String id)
Creates a new DateLabel defaulting to using a short date pattern- Parameters:
id
- The id of the text field- Returns:
- new instance
- See Also:
TextField
-
forShortStyle
public static DateLabel forShortStyle(String id, IModel<Date> model)
Creates a new DateLabel defaulting to using a short date pattern- Parameters:
id
- The id of the text fieldmodel
- The model- Returns:
- new instance
- See Also:
TextField
-
withConverter
public static DateLabel withConverter(String id, DateConverter converter)
Creates a new DateLabel using the provided converter.- Parameters:
id
- The id of the text fieldconverter
- the date converter- Returns:
- new instance
- See Also:
TextField
-
withConverter
public static DateLabel withConverter(String id, IModel<Date> model, DateConverter converter)
Creates a new DateLabel using the provided converter.- Parameters:
id
- The id of the text fieldmodel
- The modelconverter
- the date converter- Returns:
- new instance
- See Also:
TextField
-
getAfter
public String getAfter()
- Returns:
- after append to label or null
-
getBefore
public String getBefore()
- Returns:
- before prepend to label or null
-
createConverter
protected IConverter<?> createConverter(Class<?> type)
Returns the specialized converter.- Overrides:
createConverter
in classComponent
-
setAfter
public void setAfter(String after)
- Parameters:
after
- append to label
-
setBefore
public void setBefore(String before)
- Parameters:
before
- prepend to label
-
onComponentTagBody
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
- Overrides:
onComponentTagBody
in classLabel
-
-