Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package JSF Composite Component into JAR

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?

like image 350
Tony Scialo Avatar asked Jan 30 '18 18:01

Tony Scialo


1 Answers

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.

like image 138
BalusC Avatar answered Nov 15 '22 13:11

BalusC