| 1 package com.icesoft.faces.facelets; 2 3 import com.sun.facelets.tag.TagLibrary; 4 import com.sun.facelets.tag.TagHandler; 5 import com.sun.facelets.tag.TagConfig; 6 import com.sun.facelets.tag.Tag; 7 import com.sun.facelets.tag.jsf.ComponentConfig; 8 import com.sun.facelets.tag.jsf.ComponentHandler; 9 import com.sun.facelets.FaceletHandler; 10 import com.icesoft.faces.component.UIXhtmlComponent; 11 12 import javax.faces.FacesException; 13 import java.lang.reflect.Method ; 14 15 19 public class UIXhtmlTagLibrary implements TagLibrary { 20 static final String NAMESPACE = 21 "http://www.icesoft.com/icefaces/html/internal"; 22 private static final String [] MATCHING_NAMESPACES = new String [] { 23 NAMESPACE, 24 "http://www.w3.org/1999/xhtml", 25 "" 26 }; 27 28 public UIXhtmlTagLibrary() { 29 super(); 30 } 31 32 35 public boolean containsNamespace(String ns) { 36 boolean matches = false; 37 if( ns == null ) 38 matches = true; 39 else { 40 for(int i = 0; i < MATCHING_NAMESPACES.length; i++) { 41 if( ns.equals(MATCHING_NAMESPACES[i]) ) { 42 matches = true; 43 break; 44 } 45 } 46 } 47 return matches; 49 } 50 51 54 public boolean containsTagHandler(String ns, String localName) { 55 return containsNamespace( ns ); 57 } 58 59 62 public TagHandler createTagHandler( 63 String ns, String localName, TagConfig tagConfig) throws FacesException 64 { 65 ComponentConfig ccfg = new ComponentConfigWrapper( 67 tagConfig, 68 UIXhtmlComponent.COMPONENT_FAMILY, 69 UIXhtmlComponent.RENDERER_TYPE); 70 return new UIXhtmlComponentHandler(ccfg); 71 } 72 73 76 public boolean containsFunction(String ns, String name) { 77 return false; 78 } 79 80 83 public Method createFunction(String ns, String name) { 84 return null; 85 } 86 87 88 private static class ComponentConfigWrapper implements ComponentConfig { 89 private final TagConfig wrapped; 90 private final String componentType; 91 private final String rendererType; 92 93 public ComponentConfigWrapper( 94 TagConfig parent, String componentType, String rendererType) 95 { 96 this.wrapped = parent; 97 this.componentType = componentType; 98 this.rendererType = rendererType; 99 } 100 101 public String getComponentType() { 102 return componentType; 103 } 104 105 public String getRendererType() { 106 return rendererType; 107 } 108 109 public FaceletHandler getNextHandler() { 110 return wrapped.getNextHandler(); 111 } 112 113 public Tag getTag() { 114 return wrapped.getTag(); 115 } 116 117 public String getTagId() { 118 return wrapped.getTagId(); 119 } 120 } 121 } 122 | Popular Tags |