-
Notifications
You must be signed in to change notification settings - Fork 4
composite_components
Frank Broda edited this page Jun 18, 2020
·
2 revisions
- Define composite component. The component has to be placed in a folder below
resources/. We choose to useresources/crimsy/. Make sure to declare all elements, which might be edited or from which actions may originate in the interfaces section. See also examples in the documentation or on the web.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:composite="http://java.sun.com/jsf/composite"> <composite:interface name="testItemEdit" displayName="testItemEdit" preferred="true" expert="false" shortDescription="test item edit"> <composite:attribute name="item" required="true" > <composite:editableValueHolder name="bla" /> <composite:attribute name="increment" method-signature="void increment()" /> </composite:attribute> </composite:interface> <!-- not sure, whether nesting of composite:attribute etc. has been done correctly --> <composite:implementation > <!-- this is editable (needs composite:editableValueHolder) --> <h:inputText id="bla" value="#{cc.attrs.item.bla}" /> <!-- just plain value (declared by outer composite:attribute) --> #{cc.attrs.item.foo} <!-- source of actions (must be declared with composite:attribute or composite:actionSource) --> <p:commandButton id="inc" value="Inc" action="#{cc.attrs.item.increment}" update="@form" /> </composite:implementation> </html>
- Define a class and a bean
- Use the new component on some page:
<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:crimsy="http://java.sun.com/jsf/composite/crimsy"> <h:body> <h:form id="testForm"> <crimsy:testItemEdit item="#{bean.item}" rendered="#{bean.itemVisible}" /> ...