U bent hier: Home > Blog > Java > Reusable Component in ADF 11g

Reusable Component in ADF 11g


Johan Tuitel, 10 januari 2012

When I was working on a project I saw we created a few components the same, but if we had an adjustment we need to do this several times. To fix this problem you can make use of the declarativeComponent.

This component is perfect to make things work the same and maintenance easy.

1. We need to make a reusable component, create a jsff-file

  • Insert root tag with the libraries.
  • Insert in the root tag a componentDef(in which we define the content attribute’s and the content).
  • In this componentDef we add a xmlContent tag and panelGroupLayout.
  • In the xmlContent we define an attribute.
  • In the panelGroupLayout we define an inputText to show the value.

This is an example structure for the reusable component:

 <?xml version=’1.0′ encoding=”UTF-8″?>
<jsp:root xmlns:jsp=”http://java.sun.com/JSP/Page” version=”2.1″
xmlns:h=”http://java.sun.com/jsf/html
xmlns:f=”http://java.sun.com/jsf/core
xmlns:af=”http://xmlns.oracle.com/adf/faces/rich
xmlns:trh=”http://myfaces.apache.org/trinidad/html“>
<af:componentDef var=”demo” componentVar=”component”>
<af:xmlContent>
<component xmlns=”http://xmlns.oracle.com/adf/faces/rich/component“>

           <attribute>
<attribute-name>name</attribute-name>
</attribute>

</component>
</af:xmlContent>

<af:panelGroupLayout id=”demoLayout” layout=”vertical” inlineStyle=”width:1008px;”>
<af:inputText id=”demoName”
value=”#{demo.name}”
label=”Name”
readOnly=”true”
rendered=”#{demo.name != null}”
contentStyle=”color:white; font-weight: bold; font-size: 12px;”
styleClass=”DemoLabel”/>
</af:panelGroupLayout>

</af:componentDef>
</jsp:root>

2. To call this component we need to define declarativeComponent.

   <af:declarativeComponent id=”demoRegion”
viewId=”/regions/demoRegion.jsff”
name=”#{bindings.demoName.inputValue}”>

0 reacties »

Nog geen reacties.

RSS feed voor reacties op dit bericht. TrackBack URL

Plaats reactie