org.apache.wicket.markup.html.form
Class AutoLabelResolver

java.lang.Object
  extended by org.apache.wicket.markup.html.form.AutoLabelResolver
All Implemented Interfaces:
Serializable, IComponentResolver, IClusterable

public class AutoLabelResolver
extends Object
implements IComponentResolver

Resolver that implements the 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:

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.

Author:
igor, Carl-Eric Menzel
See Also:
Serialized Form

Nested Class Summary
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.
 
Field Summary
static String CSS_DISABLED_KEY
           
static String CSS_ERROR_KEY
           
static String CSS_REQUIRED_KEY
           
static MetaDataKey<AutoLabelResolver.AutoLabelMarker> MARKER_KEY
           
 
Constructor Summary
AutoLabelResolver()
           
 
Method Summary
static String getLabelIdFor(Component component)
           
 Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
          Try to resolve a component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CSS_REQUIRED_KEY

public static final String CSS_REQUIRED_KEY

CSS_DISABLED_KEY

public static final String CSS_DISABLED_KEY

CSS_ERROR_KEY

public static final String CSS_ERROR_KEY

MARKER_KEY

public static final MetaDataKey<AutoLabelResolver.AutoLabelMarker> MARKER_KEY
Constructor Detail

AutoLabelResolver

public AutoLabelResolver()
Method Detail

resolve

public Component resolve(MarkupContainer container,
                         MarkupStream markupStream,
                         ComponentTag tag)
Description copied from interface: IComponentResolver
Try to resolve a component.

Specified by:
resolve in interface IComponentResolver
Parameters:
container - The container parsing its markup
markupStream - The current markupStream
tag - The current component tag while parsing the markup
Returns:
component or null if not found

getLabelIdFor

public static final String getLabelIdFor(Component component)


Copyright © 2006–2015 Apache Software Foundation. All rights reserved.