View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.datadictionary.parse.BeanTag;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * Represents a group of HTML Radio controls. Provides preset options for the
27   * user to choose by a series of radio controls. Only one option can be selected
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  @BeanTag(name="radioGroupControl")
32  public class RadioGroupControl extends MultiValueControlBase {
33  	private static final long serialVersionUID = 8800478332086081970L;
34      private List<String> fieldsetClasses;
35  
36  
37  	private String delimiter;
38  
39  	public RadioGroupControl() {
40  		super();
41          fieldsetClasses = new ArrayList<String>();
42  	}
43  
44  	/**
45  	 * Delimiter string to be rendered between the radio group options, defaults
46  	 * to none
47  	 *
48  	 * @return String delimiter string
49  	 */
50      @BeanTagAttribute(name="delimiter")
51  	public String getDelimiter() {
52  		return this.delimiter;
53  	}
54  
55  	/**
56  	 * Setter for the string delimiter for each radio option
57  	 *
58  	 * @param delimiter delimeter to render between options
59  	 */
60  	public void setDelimiter(String delimiter) {
61  		this.delimiter = delimiter;
62  	}
63  
64      /**
65       * Get fieldsetClasses which are the classes that will be applied to this component's fieldset when generated
66       *
67       * @return css classes for the fieldset
68       */
69      @BeanTagAttribute(name="fieldsetClasses",type= BeanTagAttribute.AttributeType.LISTVALUE)
70      public List<String> getFieldsetClasses() {
71          return fieldsetClasses;
72      }
73  
74      /**
75       * Set fieldsetClasses
76       *
77       * @param fieldsetClasses css classes for the fieldset
78       */
79      public void setFieldsetClasses(List<String> fieldsetClasses) {
80          this.fieldsetClasses = fieldsetClasses;
81      }
82  
83      /**
84       * Builds the HTML class attribute string by combining the fieldsetClasses list
85       * with a space delimiter
86       *
87       * @return String class attribute string
88       */
89      public String getFieldsetClassesAsString() {
90          if (fieldsetClasses != null) {
91              return StringUtils.join(fieldsetClasses, " ");
92          }
93  
94          return "";
95      }
96  }