Reputation: 75
I developed a sample project to test composite components in JSF2.0.
Here is my sample code
My test file
<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"
xmlns:tp="http://java.sun.com/jsf/composite/test"
>
<h:body>
<h:form>
<h:outputLabel value="Success"/>
<tp:loginComponent
usernameLabel="Enter User Name: "
usernameValue="#{login.name}" />
</h:form>
</h:body>
<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="usernameLabel" />
<composite:attribute name="usernameValue" />
</composite:interface>
<composite:implementation>
<h:form>
#{cc.attrs.usernameLabel} :
<h:inputText id="username" value="#{cc.attrs.usernameValue}" />
</h:form>
</composite:implementation>
When I deploy it on Websphere 8.5 the composite component is not getting rendered.Please help me identify the issue
Thanks
Upvotes: 1
Views: 1288
Reputation: 21993
You have to adjust the location and name of the file. Otherwise JSF won't find it.
The line
xmlns:tp="http://java.sun.com/jsf/composite/test"
Points JSF to the folder resources/test
(relative to the root of your web pages). Assuming WebContent is the root for your webpages the resources folder should be inside that.
When JSF sees <tp:loginComponent .... />
it is going to look in the folder for a file called loginComponent.xhtml
.
EDIT
Because there can be many kinds of resources in your resources folder it is best to create a subfolder for components. I usually call it comps. So that would give you the path
/WebContent/resources/comps
place in this folder a file named loginComponent.xhtml
with your component.
Change the namespace line to: xmlns:tp="http://java.sun.com/jsf/composite/comps"
(that comps is in resources is implied but not specified in the URL).
See also the java ee tutorial.
Upvotes: 2