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


fiftyfive.wicket.basic
Class LabelWithPlaceholder

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
All Implemented Interfaces:
Serializable, IClusterable, IConverterLocator
Direct Known Subclasses:
FormattedLabel, TruncatedLabel

public class LabelWithPlaceholder
extends Label

An extension of Wicket's Label component that allows a placeholder value to be specified. If the label's default model is empty, then:

If the model is not empty, this behaves like the standard Label.

Example usage:

 <span wicket:id="label">Sample</span>
 
 IModel<String> emptyModel = null;
 add(new LabelWithPlaceholder("label", emptyModel).setPlaceholder("N/A"));

Since the model in this example is null, the placeholder will be used, resulting in this output:

 <span class="empty">N/A</span>

Notice also that class="empty" has been added.

Since:
2.0
See Also:
setPlaceholder(java.lang.String), Label, 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
LabelWithPlaceholder(String id)
           
LabelWithPlaceholder(String id, IModel<?> model)
           
LabelWithPlaceholder(String id, String label)
           
 
Method Summary
 String getCssClass()
          Returns "empty" if the value provided by this label's model is empty.
protected  String internalGetDefaultModelObjectAsString()
          A wrapper for Component.getDefaultModelObjectAsString() that can be overridden by subclasses.
 boolean isEmpty()
          Returns true if the model of this label is empty.
protected  void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
          Renders the label using the string value of the model as the tag body.
protected  void onDetach()
          Detaches the model that holds the placeholder value.
 LabelWithPlaceholder setPlaceholder(IModel<?> valueIfEmpty)
          Sets the value that will be used if the value provided by the label's normal model is empty.
 LabelWithPlaceholder setPlaceholder(String valueIfEmpty)
          Sets the value that will be used if the value provided by the model is empty.
 
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

LabelWithPlaceholder

public LabelWithPlaceholder(String id)
See Also:
Label.Label(String)

LabelWithPlaceholder

public LabelWithPlaceholder(String id,
                            String label)
See Also:
Label.Label(String, String)

LabelWithPlaceholder

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

getCssClass

public String getCssClass()
Returns "empty" if the value provided by this label's model is empty. Otherwise returns null.


setPlaceholder

public LabelWithPlaceholder setPlaceholder(String valueIfEmpty)
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.


setPlaceholder

public LabelWithPlaceholder setPlaceholder(IModel<?> valueIfEmpty)
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.


isEmpty

public boolean isEmpty()
Returns true if the model of this label is empty.

See Also:
Shortcuts.empty(java.lang.Object)

onDetach

protected void onDetach()
Detaches the model that holds the placeholder value.

Overrides:
onDetach in class Component

onComponentTagBody

protected void onComponentTagBody(MarkupStream markupStream,
                                  ComponentTag openTag)
Renders the label using the string value of the model as the tag body. If the value of the model is empty and placeholder was provided by setPlaceholder(java.lang.String), use the placeholder instead.

Overrides:
onComponentTagBody in class Label
See Also:
Shortcuts.empty(java.lang.Object)

internalGetDefaultModelObjectAsString

protected String internalGetDefaultModelObjectAsString()
A wrapper for Component.getDefaultModelObjectAsString() that can be overridden by subclasses.



Copyright © 2011 55 Minutes. All Rights Reserved.