public class AutoLabelResolver extends Object implements IComponentResolver
wicket:for
attribute functionality. The attribute makes it
easy to set up <label>
tags for form components by providing the following features
without having to add any additional components in code:
for
attribute with the value equivalent to the markup id of the
referenced form componentrequired
css class to the <label>
tag if the referenced form
component is required. Name of the css class can be overwritten by having a i18n property defined
for key AutoLabel.CSS.requirederror
css class to the <label>
tag if the referenced form component
has failed validation. Name of the css class can be overwritten by having a i18n property defined
for key AutoLabel.CSS.errordisabled
css class to the <label>
tag if the referenced form
component has is not enabled in hierarchy. Name of the css class can be overwritten by having a i18n property defined
for key AutoLabel.CSS.disabled
The value of the wicket:for
attribute can either contain an id of the form component or a
path to it using the standard :
path separator. Note that ..
can be used as part
of the path to construct a reference to the parent container, eg ..:..:foo:bar
. First the
value of the attribute will be treated as a path and the <label>
tag's closest parent
container will be queried for the form component. If the form component cannot be resolved the
value of the wicket:for
attribute will be treated as an id and all containers will be
searched from the closest parent to the page.
Modifier and Type | Class and Description |
---|---|
protected static class |
AutoLabelResolver.AutoLabel
Component that is attached to the
<label> tag and takes care of writing out the label
text as well as setting classes on the <label> tag |
static class |
AutoLabelResolver.AutoLabelMarker
Marker used to track whether or not a form component has an associated auto label by its mere
presense as well as some attributes of the component across requests.
|
Modifier and Type | Field and Description |
---|---|
static String |
CSS_DISABLED_KEY |
static String |
CSS_ERROR_KEY |
static String |
CSS_REQUIRED_KEY |
static String |
LABEL_ATTR |
static MetaDataKey<AutoLabelResolver.AutoLabelMarker> |
MARKER_KEY |
Constructor and Description |
---|
AutoLabelResolver() |
Modifier and Type | Method and Description |
---|---|
static String |
getLabelIdFor(Component component) |
Component |
resolve(MarkupContainer container,
MarkupStream markupStream,
ComponentTag tag)
Try to resolve a component.
|
public static final String LABEL_ATTR
public static final String CSS_REQUIRED_KEY
public static final String CSS_DISABLED_KEY
public static final String CSS_ERROR_KEY
public static final MetaDataKey<AutoLabelResolver.AutoLabelMarker> MARKER_KEY
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
IComponentResolver
resolve
in interface IComponentResolver
container
- The container parsing its markupmarkupStream
- The current markupStreamtag
- The current component tag while parsing the markupnull
if not foundCopyright © 2006–2022 Apache Software Foundation. All rights reserved.