org.apache.wicket.datetime.markup.html.basic
Class DateLabel

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.markup.html.WebComponent
          extended by org.apache.wicket.markup.html.basic.Label
              extended by org.apache.wicket.datetime.markup.html.basic.DateLabel
All Implemented Interfaces:
Serializable, IClusterable, IConverterLocator

public class DateLabel
extends Label

A label that is mapped to a java.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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor<T extends Component>, Component.VisibilityChange
 
Field Summary
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
DateLabel(String id, DateConverter converter)
          Construct with a converter.
DateLabel(String id, IModel<Date> model, DateConverter converter)
          Construct with a converter.
 
Method Summary
static DateLabel forDatePattern(String id, IModel<Date> model, String datePattern)
          Creates a new DateLabel defaulting to using a short date pattern
static DateLabel forDatePattern(String id, String datePattern)
          Creates a new DateLabel defaulting to using a short date pattern
static DateLabel forDateStyle(String id, IModel<Date> model, String dateStyle)
          Creates a new DateLabel defaulting to using a short date pattern
static DateLabel forDateStyle(String id, String dateStyle)
          Creates a new DateLabel defaulting to using a short date pattern
static DateLabel forShortStyle(String id)
          Creates a new DateLabel defaulting to using a short date pattern
static DateLabel forShortStyle(String id, IModel<Date> model)
          Creates a new DateLabel defaulting to using a short date pattern
 String getAfter()
           
 String getBefore()
           
 IConverter getConverter(Class clazz)
          Returns the specialized converter.
protected  void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
          Processes the body.
 void setAfter(String after)
           
 void setBefore(String before)
           
static DateLabel withConverter(String id, DateConverter converter)
          Creates a new DateLabel using the provided converter.
static DateLabel withConverter(String id, IModel<Date> model, 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
onRender
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, configure, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdImpl, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onConfigure, onDetach, onEndRequest, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setDefaultModel, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupIdImpl, setMarkupStream, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, toString, toString, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DateLabel

public DateLabel(String id,
                 DateConverter converter)
Construct with a converter.

Parameters:
id - The component id
converter - The converter to use

DateLabel

public DateLabel(String id,
                 IModel<Date> model,
                 DateConverter converter)
Construct with a converter.

Parameters:
id - The component id
model - The model
converter - 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 field
model - The model
datePattern - The pattern to use. Must be not null. See SimpleDateFormat for available patterns.
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 field
datePattern - The pattern to use. Must be not null. See SimpleDateFormat for available patterns.
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 field
model - The model
dateStyle - style to use in case no pattern is provided. Must be two characters from the set {"S", "M", "L", "F", "-"}. Must be not null. See DateTimeFormat.forStyle(String) for options.
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 field
dateStyle - style to use in case no pattern is provided. Must be two characters from the set {"S", "M", "L", "F", "-"}. Must be not null. See DateTimeFormat.forStyle(String) for options.
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
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 field
model - The model
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 field
converter - the date converter
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 field
model - The model
converter - the date converter
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

getConverter

public IConverter getConverter(Class clazz)
Returns the specialized converter.

Specified by:
getConverter in interface IConverterLocator
Overrides:
getConverter in class Component
Parameters:
clazz - The type to convert to
Returns:
The converter that should be used by this component

setAfter

public void setAfter(String after)
Parameters:
after - append to label

setBefore

public void setBefore(String before)
Parameters:
before - prepend to label

onComponentTagBody

protected void onComponentTagBody(MarkupStream markupStream,
                                  ComponentTag openTag)
Description copied from class: Component
Processes the body.

Overrides:
onComponentTagBody in class Label
Parameters:
markupStream - The markup stream
openTag - The open tag for the body
See Also:
Component.onComponentTagBody(org.apache.wicket.markup.MarkupStream, org.apache.wicket.markup.ComponentTag)


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.