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