This documentation is for an old version of fiftyfive-wicket (2.0.9).


fiftyfive.wicket.basic
Class TruncatedLabel

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 fiftyfive.wicket.basic.LabelWithPlaceholder
                  extended by fiftyfive.wicket.basic.TruncatedLabel
All Implemented Interfaces:
Serializable, IClusterable, IConverterLocator

public class TruncatedLabel
extends LabelWithPlaceholder

A Label that truncates its output to the specified maximum number of characters.

The string value is tested and truncated before the string is escaped into HTML entities. After the string is truncated then the resulting value is escaped. The escapeModelStrings property is honored, so you just as with a normal Label, you can disable escaping entirely if you want.

Note that if you provide a placeholder, the truncation logic will not be applied to the placeholder value.

Although the default truncation algorithm should be sufficient, you can customize it if you wish by setting the truncateHelper property. Refer to TruncateHelper.truncate() for complete details on how the default truncation rules are applied.

Usage:

 <span wicket:id="label">Dummy</span>
 
 add(new TruncatedLabel("label", 50, "My really long string that needs to be cut down to size."));

Produces:

 <span>My really long string that needs to be cut down…</span>

Since:
2.0
See Also:
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
TruncatedLabel(String id, int length)
           
TruncatedLabel(String id, int length, IModel<?> model)
           
TruncatedLabel(String id, int length, String label)
           
 
Method Summary
 TruncateHelper getTruncateHelper()
           
protected  String internalGetDefaultModelObjectAsString()
          Returns a truncated version of Component.getDefaultModelObjectAsString().
 TruncatedLabel setPlaceholder(IModel<?> valueIfEmpty)
          Sets the value that will be used if the value provided by the label's normal model is empty.
 TruncatedLabel setPlaceholder(String valueIfEmpty)
          Sets the value that will be used if the value provided by the model is empty.
 TruncatedLabel setTruncateHelper(TruncateHelper helper)
          Sets the TruncateHelper that will be used to shorten the string value.
 
Methods inherited from class fiftyfive.wicket.basic.LabelWithPlaceholder
getCssClass, isEmpty, onComponentTagBody, onDetach
 
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, 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, 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

TruncatedLabel

public TruncatedLabel(String id,
                      int length)
See Also:
LabelWithPlaceholder.LabelWithPlaceholder(String)

TruncatedLabel

public TruncatedLabel(String id,
                      int length,
                      String label)
See Also:
LabelWithPlaceholder.LabelWithPlaceholder(String, String)

TruncatedLabel

public TruncatedLabel(String id,
                      int length,
                      IModel<?> model)
See Also:
LabelWithPlaceholder.LabelWithPlaceholder(String, IModel)
Method Detail

setPlaceholder

public TruncatedLabel setPlaceholder(String valueIfEmpty)
Description copied from class: LabelWithPlaceholder
Sets the value that will be used if the value provided by the model is empty. Note that this value will be escaped based on the label's getEscapeModelStrings() flag.

Overrides:
setPlaceholder in class LabelWithPlaceholder

setPlaceholder

public TruncatedLabel setPlaceholder(IModel<?> valueIfEmpty)
Description copied from class: LabelWithPlaceholder
Sets the value that will be used if the value provided by the label's normal model is empty. For localization, consider passing in an instance of Wicket's StringResourceModel. Note that this value will be escaped based on the label's getEscapeModelStrings() flag.

Overrides:
setPlaceholder in class LabelWithPlaceholder

internalGetDefaultModelObjectAsString

protected String internalGetDefaultModelObjectAsString()
Returns a truncated version of Component.getDefaultModelObjectAsString().

Overrides:
internalGetDefaultModelObjectAsString in class LabelWithPlaceholder

getTruncateHelper

public TruncateHelper getTruncateHelper()

setTruncateHelper

public TruncatedLabel setTruncateHelper(TruncateHelper helper)
Sets the TruncateHelper that will be used to shorten the string value. Use the properties of the helper object to customize the truncation algorithm. The default helper is the one provided by the TruncateHelper empty constructor.

See Also:
TruncateHelper.TruncateHelper()


Copyright © 2011 55 Minutes. All Rights Reserved.