JSF Package Composite Component in JAR

When trying to combine our components into a jar and turn it into a dependency in another project, I performed the following <>

This works for everything except the implementation of the composite component. 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 is as follows:

 <?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", which is extracted from the common jar, works correctly, but not the tag. When checking the page, only the tag is displayed.

enter image description here

Any ideas why?

+5
source share
1 answer
 CommonWebProject |-- META-INF | |-- resources | | `-- common | | |-- components | | | `-- comment.xhtml : : : 

So the relative resource path is /common/components/comment.xhtml .

but

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

The XML namespace basically says comment.xhtml is inside the /common folder. Actually this is not. It is actually located inside the /common/components folder.

Line it up.

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

I meanwhile corrected the answer you found there.

+6
source

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


All Articles