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.htmlTag;
20  
21  import javax.faces.component.UIOutput;
22  import javax.faces.context.FacesContext;
23  
24  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
25  import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFJspProperty;
26  import org.apache.myfaces.component.ForceIdAware;
27  import org.apache.myfaces.component.StyleAware;
28  import org.apache.myfaces.component.UserRoleAware;
29  import org.apache.myfaces.component.UserRoleUtils;
30  import org.apache.myfaces.component.html.util.HtmlComponentUtils;
31  
32  /**
33   * Creates an arbitrary HTML tag which encloses any child components. 
34   * The value attribute specifies the name of the generated tag.
35   * <br/>
36   * If value is an empty string then no tag will be generated, but 
37   * the child components will be rendered. This differs from setting 
38   * rendered=false, which prevents child components from being 
39   * rendered at all.
40   * <br/>
41   * You can specify some attribute to be added to the component 
42   * using f:param like this:
43   * <br/>
44   * <t:htmlTag value="span">
45   *       <f:param name="title" value="Hello world!"/>
46   * </t:htmlTag>
47   * 
48   * Unless otherwise specified, all attributes accept static values or EL expressions.
49   * 
50   * @since 1.1.7
51   * @author bdudney (latest modification by $Author: lu4242 $)
52   * @version $Revision: 691871 $ $Date: 2008-09-03 23:32:08 -0500 (Wed, 03 Sep 2008) $
53   */
54  @JSFComponent(
55          name = "t:htmlTag",
56          clazz = "org.apache.myfaces.custom.htmlTag.HtmlTag",
57          tagClass = "org.apache.myfaces.custom.htmlTag.HtmlTagTag")
58  @JSFJspProperty(
59          name = "converter",
60          returnType = "javax.faces.convert.Converter",
61          tagExcluded = true)
62  public abstract class AbstractHtmlTag extends UIOutput 
63      implements UserRoleAware, StyleAware, ForceIdAware
64  {
65      public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlTag";
66      public static final String COMPONENT_FAMILY = "javax.faces.Output";
67      private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlTagRenderer";
68  
69      public String getClientId(FacesContext context)
70      {
71          String clientId = HtmlComponentUtils.getClientId(this,
72                  getRenderer(context), context);
73          if (clientId == null)
74          {
75              clientId = super.getClientId(context);
76          }
77  
78          return clientId;
79      }
80      
81      public boolean isRendered()
82      {
83          if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
84          return super.isRendered();
85      }
86  
87  }