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.widget;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.uif.component.Component;
21  import org.kuali.rice.krad.uif.view.View;
22  
23  /**
24   * Widget that renders a Tooltip on a component
25   *
26   * <p>
27   * Tooltips can display extra information about an element. The content can be plain text or rich HTML. Tooltips
28   * can be triggered by focus or mouse hover events.
29   * </p>
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  @BeanTag(name="tooltip")
34  public class Tooltip extends WidgetBase {
35  
36      private String tooltipContent;
37  
38      private boolean onFocus;
39      private boolean onMouseHover;
40  
41      public Tooltip() {
42          super();
43      }
44  
45      /**
46       * @see org.kuali.rice.krad.uif.component.ComponentBase#performFinalize(org.kuali.rice.krad.uif.view.View,
47       *      Object, org.kuali.rice.krad.uif.component.Component)
48       */
49      @Override
50      public void performFinalize(View view, Object model, Component parent) {
51          super.performFinalize(view, model, parent);
52      }
53  
54      /**
55       * Plain text or HTML string that will be used to render the tooltip div
56       *
57       * @return String
58       */
59      @BeanTagAttribute(name="tooltipContent")
60      public String getTooltipContent() {
61          return tooltipContent;
62      }
63  
64      /**
65       * Setter for the tooltip content text
66       *
67       * @param tooltipContent
68       */
69      public void setTooltipContent(String tooltipContent) {
70          this.tooltipContent = tooltipContent.replace("\"", "&quot;").replace("'", "&apos;");
71      }
72  
73      /**
74       * Indicates the tooltip should be triggered by focus/blur
75       *
76       * @return boolean
77       */
78      @BeanTagAttribute(name="onFocus")
79      public boolean isOnFocus() {
80          return onFocus;
81      }
82  
83      /**
84       * Setter for the onFocus
85       *
86       * @param onFocus
87       */
88      public void setOnFocus(boolean onFocus) {
89          this.onFocus = onFocus;
90      }
91  
92      /**
93       * Indicates the tooltip should be triggered by mouse hover
94       *
95       * @return boolean
96       */
97      @BeanTagAttribute(name="onMouseHover")
98      public boolean isOnMouseHover() {
99          return onMouseHover;
100     }
101 
102     /**
103      * Setter for onMouseHover
104      *
105      * @param onMouseHover
106      */
107     public void setOnMouseHover(boolean onMouseHover) {
108         this.onMouseHover = onMouseHover;
109     }
110 }