如何将多个 JSF2 复合组件库捆绑在一个名称空间下
我们有一堆 JSF 1.2 Facelets 组件 (ui:composition
)。它们被组织在不同的文件夹中,如下所示...
facelets
/tags
/inputfields
/layout
/core
/...
它们在一个名称空间下的标记库描述符中注册:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://www.ourcompany.de/jsf</namespace>
<tag>
<tag-name>desktop</tag-name>
<source>./facelets/tags/layout/desktop.xhtml</source>
</tag>
<tag>
<tag-name>inputField</tag-name>
<source>./facelets/tags/inputfields/inputField.xhtml</source>
</tag>
...
</facelet-taglib>
我们希望它们成为 JSF 2 复合组件,并希望将它们组织在单独的文件夹中。按照惯例,如果将它们移动到 /resources
文件夹中,JSF 2 就会将它们作为复合组件提供。但是每个子文件夹必须使用不同的命名空间才能使用视图中的组件。
不幸的是,像下面这样的东西不起作用,因为只能声明一个复合库名称:
<facelet-taglib version="2.0" 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">
<namespace>http://ourcompany.de/jsftags</namespace>
<composite-library-name>components/input</composite-library-name>
<composite-library-name>components/core</composite-library-name>
<composite-library-name>components/layout</composite-library-name>
</facelet-taglib>
有没有一种方法可以为所有复合组件使用相同的名称空间,而不将它们移动到一个文件夹中?
We have a bunch of JSF 1.2 facelets components (ui:composition
). They are organized in different folders like this...
facelets
/tags
/inputfields
/layout
/core
/...
They are registered within a tag library descriptor under one namespace:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://www.ourcompany.de/jsf</namespace>
<tag>
<tag-name>desktop</tag-name>
<source>./facelets/tags/layout/desktop.xhtml</source>
</tag>
<tag>
<tag-name>inputField</tag-name>
<source>./facelets/tags/inputfields/inputField.xhtml</source>
</tag>
...
</facelet-taglib>
We want them to become JSF 2 composite components and would like to keep them organized in separate folders. By convention JSF 2 makes them available as composite components, if they are moved into the /resources
folder. But different namespaces have to be used for each subfolder in order to use the components in the view.
Unfortunately, something like the following does not work, since only one composite-library-name may be declared:
<facelet-taglib version="2.0" 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">
<namespace>http://ourcompany.de/jsftags</namespace>
<composite-library-name>components/input</composite-library-name>
<composite-library-name>components/core</composite-library-name>
<composite-library-name>components/layout</composite-library-name>
</facelet-taglib>
Is there a way to use the same namespace for all of our composite components without moving them into one folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将组件移动到几个以文件夹名称命名的 servlet 3.0 Web 片段,例如 input 或 core。每个片段都有一个子文件夹
META-INF/resources/yourBaseFolderName
。当您将片段合并到一个 Web 应用程序中时,容器会将内容合并到一个可以通过公共命名空间寻址的文件夹中。You can move your components to a couple of servlet 3.0 web-fragments named by your folder names eg input or core. Each of those fragments has a subfolder
META-INF/resources/yourBaseFolderName
. When you combine the fragments into one web application, the container will merge the content into one folder that can be addressed by a common namespace.