How to bundle multiple JSF2 components in a single namespace

We have a bunch of facets JSF 1.2 components ( ui:composition ). They are organized in different folders, such as ...

 facelets /tags /inputfields /layout /core /... 

They are registered in the tag library descriptor in the same 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 be components of JSF 2 and would like to keep them in separate folders. By convention, JSF 2 makes them available as composite components if they are moved to the /resources folder. But for each subfolder, you must use different namespaces to use components in the view.

Unfortunately, something like the following does not work, since only one compound library name can 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 component components without moving them to the same folder?

+4
source share
1 answer

You can move your components to a couple of servlet 3.0 web fragments called your folder names, such as input or kernel. Each of these fragments has a subfolder META-INF/resources/yourBaseFolderName . When you combine fragments into one web application, the container combines the contents into one folder, which can be resolved using a common namespace.

0
source

Source: https://habr.com/ru/post/1391279/


All Articles