View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.custom.popup;
20  
21  import javax.faces.component.UIComponent;
22  import javax.faces.component.UIComponentBase;
23  
24  import org.apache.myfaces.component.EventAware;
25  import org.apache.myfaces.component.UniversalProperties;
26  import org.apache.myfaces.component.UserRoleAware;
27  import org.apache.myfaces.component.UserRoleUtils;
28  
29  /**
30   * Renders a popup which displays on a mouse event. 
31   * 
32   * Unless otherwise specified, all attributes accept static values or EL expressions.
33   * 
34   * @JSFComponent
35   *   name = "t:popup"
36   *   class = "org.apache.myfaces.custom.popup.HtmlPopup"
37   *   tagClass = "org.apache.myfaces.custom.popup.HtmlPopupTag"
38   * @since 1.1.7
39   * @author Martin Marinschek (latest modification by $Author: lu4242 $)
40   * @version $Revision: 1097467 $ $Date: 2011-04-28 09:11:52 -0500 (Thu, 28 Apr 2011) $
41   */
42  public abstract class AbstractHtmlPopup
43          extends UIComponentBase implements 
44          UniversalProperties, EventAware, UserRoleAware
45  {
46      //private static final Log log = LogFactory.getLog(HtmlPopup.class);
47      public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPopup";
48      public static final String COMPONENT_FAMILY = "javax.faces.Panel";
49      private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Popup";
50  
51      private static final String POPUP_FACET_NAME            = "popup";
52  
53      public void setPopup(UIComponent popup)
54      {
55          getFacets().put(POPUP_FACET_NAME, popup);
56      }
57  
58      public UIComponent getPopup()
59      {
60          return (UIComponent)getFacets().get(POPUP_FACET_NAME);
61      }
62  
63      public boolean getRendersChildren()
64      {
65          return true;
66      }
67      
68      public boolean isRendered()
69      {
70          if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
71          return super.isRendered();
72      }
73  
74      /**
75       * HTML: CSS styling instructions.
76       * 
77       * @JSFProperty
78       */
79      public abstract String getStyle();
80  
81      /**
82       *  The CSS class for this element. Corresponds to the HTML 'class' attribute.
83       * 
84       * @JSFProperty
85       */
86      public abstract String getStyleClass();
87  
88      /**
89       * Pop the panel up in horizontal distance of x pixels from event.
90       * 
91       * @JSFProperty
92       */
93      public abstract Integer getDisplayAtDistanceX();
94  
95      /**
96       * Pop the panel up in vertical distance of y pixels from event.
97       * 
98       * @JSFProperty
99       */
100     public abstract Integer getDisplayAtDistanceY();
101 
102     /**
103      * Close the popup when the triggering element is left.
104      * 
105      * @JSFProperty
106      */
107     public abstract Boolean getClosePopupOnExitingElement();
108 
109     /**
110      * Close the popup when the popup itself is left.
111      * 
112      * @JSFProperty
113      */
114     public abstract Boolean getClosePopupOnExitingPopup();
115     
116     /**
117      * The type of layout markup to use when rendering this group. If the value is "block"
118      * the renderer must produce an HTML "div" element. If the value is "none", no tag is
119      * rendered on the output and instead, onmouseover and onmouseout properties are modified
120      * for children components. Otherwise HTML "span" element must be produced.
121      *
122      * @JSFProperty
123      * @return  the new layout value
124      */
125     public abstract String getLayout();
126     
127 }