Custom JSF component declared in .tld file works in JSP but not in Facelets -
i have custom jsf component registered in .tld
file. works fine in jsp when declare below:
<%@taglib uri="http://example.com/ui" prefix="ex"%>
however, doesn't work in facelets when try declare below:
<html xmlns:ex="http://example.com/ui">
how can use custom jsf component in facelets too?
jsp , facelets entirely distinct view technologies. jsp servlet based while facelets xml based. can't reuse tags/taglibs of 1 on other. *.tld
files jsp are, *.taglib.xml
files facelets.
here's kickoff example of how facelets taglib file jsf 2.0:
<?xml version="1.0" encoding="utf-8"?> <facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0"> <namespace>http://example.com/ui</namespace> <tag> <tag-name>foo</tag-name> <component> <component-type>com.example.foo</component-type> </component> </tag> </facelet-taglib>
if have component library in flavor of jar file, drop in /meta-inf
folder. auto-discovered. if have custom components coupled in war itself, drop in /web-inf
folder , register in web.xml
via below context param:
<context-param> <param-name>javax.faces.facelets_libraries</param-name> <param-value>/web-inf/example-ui.taglib.xml</param-value> </context-param>
if indend pick jsf 2.2 minimum requirement, update taglib's root declaration below:
<facelet-taglib xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd" version="2.2">
see also:
- migrating jsf 1.2 jsf 2.0
- mojarra's jsp facelets migration guide
- why facelets preferred on jsp view definition language jsf2.0 onwards?
noted should jsp since 2009 deprecated view technology jsf. if intend build new custom component library, making jsp compatible complete waste of effort no 1 sane jsf developer use it. moreover, practically jsf 2.x component libraries don't support jsp (anymore).
Comments
Post a Comment