0

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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Rich
  • 2,805
  • 8
  • 42
  • 53
  • 1
    That seems to be a toolkit (IDE/compiler/etc) warning and not a runtime warning. What happens when you actually run the code? Just to be sure as some tools are not as smart as they pretend to be. – BalusC Feb 22 '13 at 15:56
  • Sorry, I should have been more clear. Yes there is a toolkit warning, but the actual warning I posted here is at runtime within the browser. – Rich Feb 22 '13 at 18:11
  • If you are using Eclipse/STS your 'resources' folder should be under WebContent folder. – rootkit Feb 22 '13 at 18:16
  • @rootkit, is that an answer? I don't know I understand what the WebContent folder is. The project is configured as a maven project in eclipse. – Rich Feb 22 '13 at 18:18
  • In my maven/Spring/faceted Eclipse project I have WebContent folder directly under project root - this is where WEB-INF etc resides. Try moving your resources folder there. – rootkit Feb 22 '13 at 18:21
  • Hmm, seems a bit too configuration specific, WebContent just doesn't really apply for me. I have tried the myjsf directory tree in WEB-INF/classes (which is where our classpath typically resolves from in this project). Also in src/main/webapp. I guess your suggestion is most similar to doing something like creating WEB-INF/resources and then plugging the myjsf tree in there. Is this just how you have resources setup in your project, or have you also used this to access the tablibrary for defined composite jsf components in your project? – Rich Feb 22 '13 at 18:31
  • The "WebContent" is the folder containing all deployed web resources. It's the default folder name when you create a standard (non-Mavenized) *Dynamic Web Project* in Eclipse. It's exactly that folder which in turn contains the `/WEB-INF` folder. So, basically, the composites (and JS/CSS/image) resources should end up in `/resources` folder of the "WebContent" (that folder thus ends up at the same level as `/WEB-INF` folder). They should not end up in the classpath like Java resources at all. – BalusC Feb 22 '13 at 18:33
  • Okay that certainly clarifies the setup for me, thanks. We haven't been using Dynamic Web Project, something to look into. But now I understand the mapping of WebContent, in the pure maven setup that relates to src/main/webapp – Rich Feb 22 '13 at 18:37

1 Answers1

5

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.

partlov
  • 13,789
  • 6
  • 63
  • 82