org.apache.wicket.markup.html.form
Class AutoLabelResolver
java.lang.Object
org.apache.wicket.markup.html.form.AutoLabelResolver
- All Implemented Interfaces:
- Serializable, IClusterable, IComponentResolver
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:
- Outputs the
for attribute with the value equivalent to the markup id of the
referenced form component
- Appends
required css class to the <label> tag if the referenced form
component is required
- Appends
error css class to the <label> tag if the referenced form component
has failed validation
- Appends
disabled css class to the <label> tag if the referenced form
component has is not enabled in hierarchy
The value of the wicket:for atribute 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.
<<<<<<< .mine
=======
Given markup like this:
[label wicket:for="name"][span class="label-text"]Name[/span]:[/label][input wicket:id="name" type="text"/]
If the name component has its label set to 'First Name' the resulting output will be:
[label for="name5"][span class="label-text"]First Name[/span]:[/label][input name="name" type="text" id="name5"/]
However, if the name component does not have a label set then it will be set to
Name based on the markup.
>>>>>>> .r1146946
- 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 |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AutoLabelResolver
public AutoLabelResolver()
resolve
public boolean resolve(MarkupContainer container,
MarkupStream markupStream,
ComponentTag tag)
- Description copied from interface:
IComponentResolver
- Try to resolve the tag, then create a component, add it to the container and render it.
- Specified by:
resolve in interface IComponentResolver
- Parameters:
container - The container parsing its markupmarkupStream - The current markupStreamtag - The current component tag while parsing the markup
- Returns:
- True if component-id was handled by the resolver, false otherwise.
Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.