View Javadoc

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