Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Copyright 2006, 2007, 2008, 2009, 2010 The Apache Software Foundation
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
 package org.apache.tapestry5.corelib.components;
Generates a <label> element for a particular field.

A Label will render its body, if it has one. However, in most cases it will not have a body, and will render its field's label as it's body. Remember, however, that it is the field label that will be used in any error messages. The Label component allows for client- and server-side validation error decorations.

 public class Label
The for parameter is used to identify the org.apache.tapestry5.Field linked to this label (it is named this way because it results in the for attribute of the label element).
     @Parameter(name = "for", required = true, allowNull = false, defaultPrefix = .)
     private Field field;
     private ValidationDecorator decorator;
     private ComponentResources resources;

If true, then the body of the label element (in the template) is ignored. This is used when a designer places a value inside the <label> element for WYSIWYG purposes, but it should be replaced with a different (probably, localized) value at runtime. The default is false, so a body will be used if present and the field's label will only be used if the body is empty or blank.
     private boolean ignoreBody;
     private Element labelElement;
     boolean beginRender(MarkupWriter writer)
          = writer.element("label");
         // Since we don't know if the field has rendered yet, we need to defer writing the for and id
         // attributes until we know the field has rendered (and set its clientId property). That's
         // exactly what Heartbeat is for.
         return !;
     private void updateAttributes()
         String fieldId = .getClientId();
     void afterRender(MarkupWriter writer)
         // If the Label element has a body that renders some non-blank output, that takes precedence
         // over the label string provided by the field.
         boolean bodyIsBlank = InternalUtils.isBlank(.getChildMarkup());
         if (bodyIsBlank)
        writer.end(); // label
New to GrepCode? Check out our FAQ X