5

When attempting to bundle our composite components into a jar and include as a dependency in another project, I followed the following answer.

This works for everything except the composite component implementation. The folder structure for our common project is shown below:

CommonWebProject
 |-- META-INF
 |    |-- resources
 |    |    `-- common
 |    |         |-- css
 |    |         |    ...
 |    |         |-- js
 |    |         |    ...
 |    |         |-- components
 |    |         |    `-- comment.xhtml
 |    |         |-- templates
 |    |         |    `-- defaultTemplate.xhtml
 |    |-- faces-config.xml
 |    `-- MANIFEST.MF
 :

comment.xhtml consists of:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>

</composite:interface>

<composite:implementation>
  <p>TESTING!</p>
</composite:implementation>

</html> 

The actual implementation looks like:

<?xml version="1.0" encoding="UTF-8" ?>
  <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:csxc="http://java.sun.com/jsf/composite/csxcomponent" xmlns:p="http://primefaces.org/ui"
    xmlns:common="http://java.sun.com/jsf/composite/common"
    template="/common/templates/defaultTemplate.xhtml">
    <ui:define name="head">
    </ui:define>

    <common:comment/>

  </ui:composition> 

Here the template "defaultTemplate.xhtml" that is being pulled from the common jar is working correctly, but not the tag. Inspecting the page just shows the tag.

enter image description here

Any ideas why?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Tony Scialo
  • 5,457
  • 11
  • 35
  • 52
  • Does it work when you include all in your project directly? Anything special in your faces-config.xml? Anything special in your web.xml? Versions? – Kukeltje Jan 30 '18 at 19:46

1 Answers1

8
CommonWebProject
 |-- META-INF
 |    |-- resources
 |    |    `-- common
 |    |         |-- components
 |    |         |    `-- comment.xhtml
 :    :         :

Thus, the resource-relative path is /common/components/comment.xhtml.

However,

xmlns:common="http://java.sun.com/jsf/composite/common"
...
<common:comment />

the XML namespace basically says that comment.xhtml is inside /common folder. It's actually not there. It's actually inside /common/components folder.

Align out it.

xmlns:common="http://java.sun.com/jsf/composite/common/components"
...
<common:comment />

I have in the meanwhile fixed the answer you found there.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555