<ui:composition xmlns="http://www.w3.org/1999/xhtml"
...
template="inputLayout.xhtml">
<composite:interface>
<composite:attribute name="name" />
<composite:attribute name="value" />
</composite:interface>
<composite:implementation>
<!-- <ui:define name="content"> -->
<h:message for="textPanel" style="color:red;" />
#{cc.attrs.name} :
<h:inputText id="name" value="#{cc.attrs.value}" />
<!-- <ui:define> -->
</composite:implementation>
</ui:composition>
The problem is that even the ui:define is commented the content is rendered. So it is like the ui:define is ignored or Am I missing some thing ? Thanks.
Tags:component| jsf2 Since JSF 2.0, it’s very easy to create a reusable component, known as composite components. In this tutorial, we show you how to create a simple composite components (stored as “register.xhtml“), which is an user registration form, includes name and email text fields (h:inputText) and a submit button (h:commandButton).
JSF provides the developers with a powerful capability to define their own custom components, which can be used to render custom contents. Defining a custom component in JSF is a two-step process. Create a resources folder. Create a xhtml file in resources folder with a composite namespace.
JSF2.0 refers to those components that you’ve implemented with the composite library as composite components. Composing a new component is very easy, cause no need for writing a java code or adding an XML.
Create a xhtml file in resources folder with a composite namespace. Use composite tags composite:interface, composite:attribute and composite:implementation, to define content of the composite component. Use cc.attrs in composite:implementation to get variable defined using composite:attribute in composite:interface.
This will indeed not work. You need <ui:decorate>
inside the implementation instead.
<ui:component
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:cc="http://java.sun.com/jsf/composite"
>
<cc:interface>
...
</cc:interface>
<cc:implementation>
<ui:decorate template="/WEB-INF/inputLayout.xhtml">
<ui:define name="content">
...
</ui:define>
</ui:decorate>
</cc:implementation>
</ui:component>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With