View Javadoc
1   /**
2    * Copyright 2005-2014 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.widget;
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.uif.CssConstants;
22  import org.kuali.rice.krad.uif.component.Component;
23  import org.kuali.rice.krad.uif.util.LifecycleElement;
24  
25  /**
26   * Decorates a group with scroll functionality.
27   *
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  @BeanTag(name = "scrollpane", parent = "Uif-Scrollpane")
31  public class Scrollpane  extends WidgetBase {
32      private static final long serialVersionUID = 3853028195825084261L;
33  
34      private String height;
35  
36      @Override
37      public void performFinalize(Object model, LifecycleElement parent) {
38          super.performFinalize(model, parent);
39  
40          if (parent instanceof Component) {
41              buildCSSforScrollPane((Component) parent);
42          }
43      }
44  
45      private void buildCSSforScrollPane(Component parent) {
46          if (StringUtils.isNotBlank(getHeight())) {
47              if (!StringUtils.contains(parent.getStyle(), CssConstants.HEIGHT)) {
48                  parent.appendToStyle(CssConstants.HEIGHT + getHeight() +";");
49              }
50  
51              if (!StringUtils.contains(parent.getStyle(), CssConstants.OVERFLOW)) {
52                  parent.appendToStyle(CssConstants.OVERFLOW + "auto;");
53              }
54          }
55      }
56  
57      /**
58       * Height the content should take up in the group
59       *
60       * <p>
61       * If the content size exceeds the height then a scroll bar will be shown.
62       * </p>
63       * <p>
64       * e.g. '30%' or '55px'
65       * </p>
66       *
67       * @return Content height of the group
68       */
69      @BeanTagAttribute
70      public String getHeight() {
71          return height;
72      }
73  
74      /**
75       * Setter for the group height
76       *
77       * @param height
78       */
79      public void setHeight(String height) {
80          this.height = height;
81      }
82  
83  }