Coverage Report - org.kuali.rice.krad.uif.control.TextAreaControl
 
Classes in this File Line Coverage Branch Coverage Complexity
TextAreaControl
0%
0/31
0%
0/8
1.286
 
 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.krad.uif.control;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.krad.uif.container.View;
 20  
 import org.kuali.rice.krad.uif.core.Component;
 21  
 import org.kuali.rice.krad.uif.field.AttributeField;
 22  
 
 23  
 /**
 24  
  * Represents a HTML TextArea control. Generally used for values that are very
 25  
  * large (such as a description)
 26  
  *
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public class TextAreaControl extends ControlBase {
 30  
     private static final long serialVersionUID = -4664558047325456844L;
 31  
 
 32  
     private int rows;
 33  
     private int cols;
 34  
     private Integer maxLength;
 35  
     private Integer minLength;
 36  
 
 37  
     private boolean textExpand;
 38  0
     private String watermarkText = StringUtils.EMPTY;
 39  
 
 40  
     public TextAreaControl() {
 41  0
         super();
 42  0
     }
 43  
 
 44  
     /**
 45  
      * The following actions are performed:
 46  
      *
 47  
      * <ul>
 48  
      * <li>Defaults maxLength, minLength (if not set) to maxLength of parent field</li>
 49  
      * </ul>
 50  
      *
 51  
      * @see org.kuali.rice.krad.uif.core.ComponentBase#performFinalize(org.kuali.rice.krad.uif.container.View,
 52  
      *      java.lang.Object, org.kuali.rice.krad.uif.core.Component)
 53  
      */
 54  
     @Override
 55  
     public void performFinalize(View view, Object model, Component parent) {
 56  0
         super.performFinalize(view, model, parent);
 57  
 
 58  0
         if (parent instanceof AttributeField) {
 59  0
             AttributeField field = (AttributeField) parent;
 60  0
             if (getMaxLength() == null) {
 61  0
                 setMaxLength(field.getMaxLength());
 62  
             }
 63  
 
 64  0
             if (getMinLength() == null) {
 65  0
                 setMinLength(field.getMinLength());
 66  
             }
 67  
         }
 68  0
     }
 69  
 
 70  
     /**
 71  
      * Number of rows the control should span (horizontal length)
 72  
      *
 73  
      * @return int number of rows
 74  
      */
 75  
     public int getRows() {
 76  0
         return this.rows;
 77  
     }
 78  
 
 79  
     public void setRows(int rows) {
 80  0
         this.rows = rows;
 81  0
     }
 82  
 
 83  
     /**
 84  
      * Number of columns the control should span (vertical length)
 85  
      *
 86  
      * @return int number of columns
 87  
      */
 88  
     public int getCols() {
 89  0
         return this.cols;
 90  
     }
 91  
 
 92  
     public void setCols(int cols) {
 93  0
         this.cols = cols;
 94  0
     }
 95  
 
 96  
     /**
 97  
      * Maximum number of characters that can be inputted
 98  
      *
 99  
      * <p>If not set on control, max length of field will be used</p>
 100  
      *
 101  
      * @return int max number of characters
 102  
      */
 103  
     public Integer getMaxLength() {
 104  0
         return maxLength;
 105  
     }
 106  
 
 107  
     /**
 108  
      * Setter for the max number of input characters
 109  
      *
 110  
      * @param maxLength
 111  
      */
 112  
     public void setMaxLength(Integer maxLength) {
 113  0
         this.maxLength = maxLength;
 114  0
     }
 115  
 
 116  
     /**
 117  
      * Minimum number of characters that can be inputted
 118  
      *
 119  
      * <p>If not set on control, min length of field will be used</p>
 120  
      *
 121  
      * @return int max number of characters
 122  
      */
 123  
     public Integer getMinLength() {
 124  0
         return minLength;
 125  
     }
 126  
 
 127  
     /**
 128  
      * Setter for the min number of input characters
 129  
      *
 130  
      * @param maxLength
 131  
      */
 132  
     public void setMinLength(Integer minLength) {
 133  0
         this.minLength = minLength;
 134  0
     }
 135  
 
 136  
     /**
 137  
      * @return the watermarkText
 138  
      */
 139  
     public String getWatermarkText() {
 140  0
         return this.watermarkText;
 141  
     }
 142  
 
 143  
     /**
 144  
      * @param watermarkText the watermarkText to set
 145  
      */
 146  
     public void setWatermarkText(String watermarkText) {
 147  
         //to avoid users from putting in the same value as the watermark adding some spaces here
 148  
         //see watermark troubleshooting for more info
 149  0
         if (StringUtils.isNotEmpty(watermarkText)) {
 150  0
             watermarkText = watermarkText + "   ";
 151  
         }
 152  0
         this.watermarkText = watermarkText;
 153  0
     }
 154  
 
 155  
     /**
 156  
      * If set to true, this control will have a button which can be clicked to expand the text area through
 157  
      * a popup window so the user has more space to type and see the data they are entering in this text field
 158  
      *
 159  
      * @return the textExpand
 160  
      */
 161  
     public boolean isTextExpand() {
 162  0
         return this.textExpand;
 163  
     }
 164  
 
 165  
     /**
 166  
      * @param textExpand the textExpand to set
 167  
      */
 168  
     public void setTextExpand(boolean textExpand) {
 169  0
         this.textExpand = textExpand;
 170  0
     }
 171  
 
 172  
 
 173  
 }