Class Label

  • All Implemented Interfaces:
    Serializable, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IMetadataContext<Serializable,​Component>, IHeaderContributor, IRequestableComponent, org.apache.wicket.util.IHierarchical<Component>, org.apache.wicket.util.io.IClusterable

    public class Label
    extends WebComponent
    A Label component replaces its body with the String version of its model object returned by getModelObjectAsString().

    Exactly what is displayed as the body, depends on the model. The simplest case is a Label with a static String model, which can be constructed like this:

     add(new Label("myLabel", "the string to display"))
     
    A Label with a dynamic model can be created like this:
     
           add(new Label("myLabel", new PropertyModel(person, "name"));
     
     
    In this case, the Label component will replace the body of the tag it is attached to with the 'name' property of the given Person object, where Person might look like:
     public class Person
     {
            private String name;
     
            public String getName()
            {
                    return name;
            }
     
            public void setName(String name)
            {
                    this.name = name;
            }
     }
     
    Author:
    Jonathan Locke
    See Also:
    Serialized Form
    • Constructor Detail

      • Label

        public Label​(String id)
        Constructor
        Parameters:
        id - See Component
      • Label

        public Label​(String id,
                     Serializable label)
        Convenience constructor. Same as Label(String, Model.of(Serializable))
        Parameters:
        id - See Component
        label - The label text or object, converted to a string via the IConverter.
        See Also:
        Component(String, IModel)
    • Method Detail

      • onComponentTagBody

        public void onComponentTagBody​(MarkupStream markupStream,
                                       ComponentTag openTag)
        Processes the body.
        Overrides:
        onComponentTagBody in class Component
        Parameters:
        markupStream - The markup stream
        openTag - The open tag for the body
      • onComponentTag

        protected void onComponentTag​(ComponentTag tag)
        Processes the component tag. Overrides of this method most likely should call the super implementation.
        Overrides:
        onComponentTag in class Component
        Parameters:
        tag - Tag to modify