【问题标题】:JSF define custom namespace for component declarationJSF 为组件声明定义自定义命名空间
【发布时间】:2011-03-31 11:29:06
【问题描述】:

当您在 JSF 页面中使用来自外部库(或自定义组件)的组件时,您添加 xmlns 声明,例如:

xmlns:util="http://java.sun.com/jsf/composite/component/util

我想知道如何在 Namaspace 中使用私有地址,如下所示:

xmlns:p="http://primefaces.prime.com.tr/ui"

这和包有关吗?还是取决于包含组件的 .JAR 的名称?

谢谢!

【问题讨论】:

    标签: jsf namespaces composite-component


    【解决方案1】:

    对于 Facelets,这是在 .taglib.xml 文件中定义的。对于 PrimeFaces,它是 /META-INF/primefaces-p.taglib.xml:

    <?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://primefaces.prime.com.tr/ui</namespace>
        ...
    

    注意&lt;namespace&gt;。对于 JSP,这是在 .tld 文件中定义的,对于 PrimeFaces,它是 /META-INF/primefaces-p.tld

    <?xml version="1.0" encoding="UTF-8"?>
    <taglib xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1">
        <tlib-version>1.2</tlib-version>
        <short-name>p</short-name>
        <uri>http://primefaces.prime.com.tr/ui</uri>
        ...
    

    注意&lt;uri&gt;

    【讨论】:

    • 我的项目中没有 /META-INF/primefaces-p.taglib.xml 这样的文件,但我使用的是 Primefaces?
    猜你喜欢
    • 1970-01-01
    • 2014-02-06
    • 2019-09-21
    • 2012-08-07
    • 2015-06-03
    • 1970-01-01
    • 2013-05-19
    • 1970-01-01
    • 2015-05-10
    相关资源
    最近更新 更多