4

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?

Tim Brückner
  • 1,928
  • 2
  • 16
  • 27

1 Answers1

-1

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.

frifle
  • 810
  • 5
  • 24