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 checkbox controls. Provides preset options for the
28   * user to choose by a series of checkbox controls. Only or more options can be
29   * select.
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @BeanTags({@BeanTag(name = "verticalCheckboxesControl", parent = "Uif-VerticalCheckboxesControl"),
34          @BeanTag(name = "horizontalCheckboxesControl", parent = "Uif-HorizontalCheckboxesControl")})
35  public class CheckboxGroupControl extends MultiValueControlBase {
36      private static final long serialVersionUID = 8800478332086081970L;
37  
38      private String delimiter;
39  
40      private List<String> fieldsetClasses;
41  
42      public CheckboxGroupControl() {
43          super();
44  
45          fieldsetClasses = new ArrayList<String>();
46      }
47  
48      /**
49       * Delimiter string to be rendered between the checkbox group options
50       *
51       * <p>
52       * defaults to none.
53       * </p>
54       *
55       * @return delimiter string
56       */
57      @BeanTagAttribute
58      public String getDelimiter() {
59          return this.delimiter;
60      }
61  
62      /**
63       * Setter for the string delimiter for each checkbox option
64       *
65       * @param delimiter
66       */
67      public void setDelimiter(String delimiter) {
68          this.delimiter = delimiter;
69      }
70  
71      /**
72       * Get fieldsetClasses which are the classes that will be applied to this component's fieldset when generated
73       *
74       * @return fieldset css classes
75       */
76      @BeanTagAttribute
77      public List<String> getFieldsetClasses() {
78          return fieldsetClasses;
79      }
80  
81      /**
82       * Set fieldsetClasses - css classes for the element
83       *
84       * @param fieldsetClasses fieldset css classes list
85       */
86      public void setFieldsetClasses(List<String> fieldsetClasses) {
87          this.fieldsetClasses = fieldsetClasses;
88      }
89  
90      /**
91       * Builds the HTML class attribute string by combining the fieldsetClasses list
92       * with a space delimiter
93       *
94       * @return class attribute string
95       */
96      public String getFieldsetClassesAsString() {
97          if (fieldsetClasses != null) {
98              return StringUtils.join(fieldsetClasses, " ");
99          }
100 
101         return "";
102     }
103 }