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 import javax.faces.convert.Converter; 24 25 import org.apache.myfaces.component.ForceIdAware; 26 import org.apache.myfaces.component.StyleAware; 27 import org.apache.myfaces.component.UserRoleAware; 28 import org.apache.myfaces.component.UserRoleUtils; 29 import org.apache.myfaces.component.html.util.HtmlComponentUtils; 30 31 /** 32 * Creates an arbitrary HTML tag which encloses any child components. 33 * The value attribute specifies the name of the generated tag. 34 * 35 * If value is an empty string then no tag will be generated, but 36 * the child components will be rendered. This differs from setting 37 * rendered=false, which prevents child components from being 38 * rendered at all. 39 * 40 * There is currently no facility for adding attributes to the 41 * generated html tag other than those explicitly supported by 42 * the attributes on this JSF component. 43 * 44 * Unless otherwise specified, all attributes accept static values or EL expressions. 45 * 46 * @JSFComponent 47 * name = "t:htmlTag" 48 * class = "org.apache.myfaces.custom.htmlTag.HtmlTag" 49 * tagClass = "org.apache.myfaces.custom.htmlTag.HtmlTagTag" 50 * @since 1.1.7 51 * @author bdudney (latest modification by $Author: lu4242 $) 52 * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (Wed, 03 Sep 2008) $ 53 */ 54 public abstract class AbstractHtmlTag extends UIOutput 55 implements UserRoleAware, StyleAware, ForceIdAware 56 { 57 public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlTag"; 58 public static final String COMPONENT_FAMILY = "javax.faces.Output"; 59 private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.HtmlTagRenderer"; 60 61 public String getClientId(FacesContext context) 62 { 63 String clientId = HtmlComponentUtils.getClientId(this, 64 getRenderer(context), context); 65 if (clientId == null) 66 { 67 clientId = super.getClientId(context); 68 } 69 70 return clientId; 71 } 72 73 public boolean isRendered() 74 { 75 if (!UserRoleUtils.isVisibleOnUserRole(this)) return false; 76 return super.isRendered(); 77 } 78 79 /** 80 * This component converts submitted values to String, so 81 * converter is not needed, not custom conversion necessary. 82 * 83 * @JSFProperty 84 * tagExcluded = "true" 85 */ 86 public Converter getConverter() 87 { 88 return null; 89 } 90 91 public void setConverter(Converter converter) 92 { 93 throw new UnsupportedOperationException(); 94 } 95 96 }