Class AutoLabelResolver
- java.lang.Object
-
- org.apache.wicket.markup.html.form.AutoLabelResolver
-
- All Implemented Interfaces:
java.io.Serializable,IComponentResolver,org.apache.wicket.util.io.IClusterable
public class AutoLabelResolver extends java.lang.Object implements IComponentResolver
Resolver that implements thewicket:forattribute 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:- Outputs the
forattribute with the value equivalent to the markup id of the referenced form component - Appends
requiredcss 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.required - Appends
errorcss 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.error - Appends
disabledcss 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:forattribute 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 thewicket:forattribute will be treated as an id and all containers will be searched from the closest parent to the page.- Author:
- igor, Carl-Eric Menzel
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAutoLabelResolver.AutoLabelComponent that is attached to the<label>tag and takes care of writing out the label text as well as setting classes on the<label>tagstatic classAutoLabelResolver.AutoLabelMarkerMarker 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.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCSS_DISABLED_KEYstatic java.lang.StringCSS_ERROR_KEYstatic java.lang.StringCSS_REQUIRED_KEYstatic java.lang.StringLABEL_ATTRstatic MetaDataKey<AutoLabelResolver.AutoLabelMarker>MARKER_KEY
-
Constructor Summary
Constructors Constructor Description AutoLabelResolver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetLabelIdFor(Component component)Componentresolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)Try to resolve a component.
-
-
-
Field Detail
-
LABEL_ATTR
public static final java.lang.String LABEL_ATTR
- See Also:
- Constant Field Values
-
CSS_REQUIRED_KEY
public static final java.lang.String CSS_REQUIRED_KEY
-
CSS_DISABLED_KEY
public static final java.lang.String CSS_DISABLED_KEY
-
CSS_ERROR_KEY
public static final java.lang.String CSS_ERROR_KEY
-
MARKER_KEY
public static final MetaDataKey<AutoLabelResolver.AutoLabelMarker> MARKER_KEY
-
-
Method Detail
-
resolve
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
Description copied from interface:IComponentResolverTry to resolve a component.- Specified by:
resolvein interfaceIComponentResolver- Parameters:
container- The container parsing its markupmarkupStream- The current markupStreamtag- The current component tag while parsing the markup- Returns:
- component or
nullif not found
-
getLabelIdFor
public static java.lang.String getLabelIdFor(Component component)
-
-