Coverage Report - org.kuali.rice.kns.uif.field.LabelField
 
Classes in this File Line Coverage Branch Coverage Complexity
LabelField
0%
0/22
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation Licensed under the Educational Community
 3  
  * License, Version 1.0 (the "License"); you may not use this file except in
 4  
  * compliance with the License. You may obtain a copy of the License at
 5  
  * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law
 6  
  * or agreed to in writing, software distributed under the License is
 7  
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 8  
  * KIND, either express or implied. See the License for the specific language
 9  
  * governing permissions and limitations under the License.
 10  
  */
 11  
 package org.kuali.rice.kns.uif.field;
 12  
 
 13  
 import java.util.List;
 14  
 
 15  
 import org.kuali.rice.kns.uif.UifConstants.Position;
 16  
 import org.kuali.rice.kns.uif.core.Component;
 17  
 
 18  
 /**
 19  
  * Contains a label for another <code>Field</code> instance
 20  
  * <p>
 21  
  * The <code>LabelField</code> exists so that the label can be placed separate
 22  
  * from the component in a layout manager such as the
 23  
  * <code>GridLayoutManager</code>. It addition it can be used to style the label
 24  
  * (from the inherited styleClass and style properties)
 25  
  * </p>
 26  
  * 
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public class LabelField extends FieldBase {
 30  
     private static final long serialVersionUID = -6491546893195180114L;
 31  
 
 32  
     private String labelText;
 33  
     private String labelForComponentId;
 34  
 
 35  
     private boolean renderColon;
 36  
 
 37  
     private String requiredMessagePlacement;
 38  
     private MessageField requiredMessageField;
 39  
 
 40  0
     public LabelField() {
 41  0
         renderColon = true;
 42  
 
 43  0
         requiredMessagePlacement = Position.LEFT;
 44  0
     }
 45  
 
 46  
     /**
 47  
      * @see org.kuali.rice.kns.uif.core.ComponentBase#getNestedComponents()
 48  
      */
 49  
     @Override
 50  
     public List<Component> getNestedComponents() {
 51  0
         List<Component> components = super.getNestedComponents();
 52  
 
 53  0
         components.add(requiredMessageField);
 54  
 
 55  0
         return components;
 56  
     }
 57  
 
 58  
     /**
 59  
      * Indicates the id for the component the label applies to
 60  
      * <p>
 61  
      * Used for setting the labelFor attribute of the corresponding HTML
 62  
      * element. Note this gets set automatically by the framework during the
 63  
      * initialize phase
 64  
      * </p>
 65  
      * 
 66  
      * @return String component id
 67  
      */
 68  
     public String getLabelForComponentId() {
 69  0
         return this.labelForComponentId;
 70  
     }
 71  
 
 72  
     /**
 73  
      * Setter for the component id the label applies to
 74  
      * 
 75  
      * @param labelForComponentId
 76  
      */
 77  
     public void setLabelForComponentId(String labelForComponentId) {
 78  0
         this.labelForComponentId = labelForComponentId;
 79  0
     }
 80  
 
 81  
     /**
 82  
      * Text that will display as the label
 83  
      * 
 84  
      * @return String label text
 85  
      */
 86  
     public String getLabelText() {
 87  0
         return this.labelText;
 88  
     }
 89  
 
 90  
     /**
 91  
      * Setter for the label text
 92  
      * 
 93  
      * @param labelText
 94  
      */
 95  
     public void setLabelText(String labelText) {
 96  0
         this.labelText = labelText;
 97  0
     }
 98  
 
 99  
     /**
 100  
      * Indicates whether a colon should be rendered after the label text,
 101  
      * generally used when the label appears to the left of the field's control
 102  
      * or value
 103  
      * 
 104  
      * @return boolean true if a colon should be rendered, false if it should
 105  
      *         not be
 106  
      */
 107  
     public boolean isRenderColon() {
 108  0
         return this.renderColon;
 109  
     }
 110  
 
 111  
     /**
 112  
      * Setter for the render colon indicator
 113  
      * 
 114  
      * @param renderColon
 115  
      */
 116  
     public void setRenderColon(boolean renderColon) {
 117  0
         this.renderColon = renderColon;
 118  0
     }
 119  
 
 120  
     /**
 121  
      * <code>MessageField</code> instance that will display a required indicator
 122  
      * 
 123  
      * <p>
 124  
      * To indicate a field must have a value (required input) the required
 125  
      * message field can be set to display an indicator or message along with
 126  
      * the label. The message field also dictates the styling of the required
 127  
      * message
 128  
      * </p>
 129  
      * 
 130  
      * @return MessageField instance
 131  
      */
 132  
     public MessageField getRequiredMessageField() {
 133  0
         return this.requiredMessageField;
 134  
     }
 135  
 
 136  
     /**
 137  
      * Setter for the required message field
 138  
      * 
 139  
      * @param requiredMessageField
 140  
      */
 141  
     public void setRequiredMessageField(MessageField requiredMessageField) {
 142  0
         this.requiredMessageField = requiredMessageField;
 143  0
     }
 144  
 
 145  
     /**
 146  
      * Indicates where the required message field should be placed in relation
 147  
      * to the label field, valid options are 'LEFT' and 'RIGHT'
 148  
      * 
 149  
      * @return the requiredMessagePlacement
 150  
      */
 151  
     public String getRequiredMessagePlacement() {
 152  0
         return this.requiredMessagePlacement;
 153  
     }
 154  
 
 155  
     /**
 156  
      * Setter for the required message field placement
 157  
      * 
 158  
      * @param requiredMessagePlacement
 159  
      */
 160  
     public void setRequiredMessagePlacement(String requiredMessagePlacement) {
 161  0
         this.requiredMessagePlacement = requiredMessagePlacement;
 162  0
     }
 163  
 
 164  
 }