Rich
Rich

Reputation: 2885

Implementing JSF Composite Component in Maven project

It seems people are able to implement composite components in SWF 2.3.1, but I cannot find a clear reference for how this is done. I have followed the basic structure for a JSF composite component, but my SWF application does not seem to recognize the taglib namespace.

There is a toolkit/IDE warning, but more importantly there is a runtime warning seen in the browser, JSF is displaying the following warning on the screen to the user:

Warning: This page calls for XML namespace http://java.sun.com/jsf/composite/myjsf declared with prefix mj but no taglibrary exists for that namespace.

Component definition:

src/main/resources/myjsf/testComponent.xhtml :

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
    <composite:attribute name="attr" />
</composite:interface>
<composite:implementation>

#{cc.attrs.attr});          

</composite:implementation>
</html>

Referenced in a given xhtml:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:mj="http://java.sun.com/jsf/composite/myjsf">

  <!-- snip -->

  <mj:testComponent attr="x" />

</ui:composition>

Upvotes: 0

Views: 1152

Answers (1)

partlov
partlov

Reputation: 14277

The folder src/main/resources/myjsf/ isn't right place for your composite component. Composite component in maven projects should be in src/main/webapp/resources/ and in your case it should be src/main/webapp/resources/myjsf/testComponent.xhtml.

As you are using Maven you should know that webapp folder is folder whose content will be deployed in root folder of your application, and thus it is somehow analogue as WebContent folder in standard dynamic web project in Eclipse.

Upvotes: 5

Related Questions