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