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