Académique Documents
Professionnel Documents
Culture Documents
1
1/19/2008
2
1/19/2008
package book.model;
import java.util.Date;
3
1/19/2008
User.java
• This java class conforms to the JavaBean
standard;
– Member variables (attributes) are private
– Accessors method
4
1/19/2008
5
1/19/2008
6
1/19/2008
User.xml
<?xml version="1.0" encoding="UTF-8" ?>
<JavaBean xmlns="http://xmlns.oracle.com/adfm/beanmodel"
version="10.1.3.36.73"
id="User" BeanClass="book.model.User" Package="book.model"
isJavaBased="true">
<Attribute Name="birthday" Type="java.util.Date"/>
<Attribute Name="name" Type="java.lang.String"/>
<MethodAccessor IsCollection="false" Type="long" id="userAge"
ReturnNodeName="Return">
<ParameterInfo id="fudgeFactor" Type="int" isStructured="false"/>
</MethodAccessor>
<ConstructorMethod IsCollection="false" Type="void" id="User"/>
</JavaBean>
User.xml
• All information to describe User.java
• Define al elements in User.java;
– each attributes,
– getter & setter and
– Methods; userAge() method with its output & input
• Never need to edit this file, if you make changes
in the User class, just regenerate the data
control definition again.
• Each java class will have it’s own XML
description file
7
1/19/2008
DataControl.dcx
<?xml version="1.0" encoding="UTF-8" ?>
<DataControlConfigs xmlns="http://xmlns.oracle.com/adfm/configuration"
version="10.1.3.36.73" Package="model" id="DataControls">
<JavaBeanDataControl SupportsTransactions="false"
SupportsFindMode="false"
SupportsResetState="false" SupportsRangesize="true"
SupportsSortCollection="true" SupportsUpdates="false"
id="UserDataControl"
xmlns="http://xmlns.oracle.com/adfm/datacontrol"
FactoryClass="oracle.adf.model.generic.DataControlFactoryImpl"
Definition="book.model.User"
BeanClass="book.model.User"/>
</DataControlConfigs>
DataControl.dcx
• Index file for all data control within a
project.
• There will only be one DataControl.dcx to
summarize all java class, within the same
project folder.
8
1/19/2008
DataControl.dcx
• SupportsTransactions is set to "false“.
• Try set it to “true” and save.
• Refresh Data Control palette, and see
what will happen.
• Return back it to “false” and save.
9
1/19/2008
10
1/19/2008
11
1/19/2008
12
1/19/2008
13
1/19/2008
New User.xml
<?xml version="1.0" encoding="UTF-8" ?>
<JavaBean xmlns="http://xmlns.oracle.com/adfm/beanmodel" version="10.1.3.36.73"
id="User" BeanClass="book.model.User" Package="book.model"
isJavaBased="true" MsgBundleClass="book.model.UserMsgBundle">
<Attribute Name="birthday" Type="java.util.Date" DefaultValue=""
PrecisionRule="false" Precision="0" Scale="0">
<CompareValidationBean xmlns="http://xmlns.oracle.com/adfm/validation"
OnAttribute="birthday" ResId="birthday_Rule_0"
OperandType="LITERAL" Inverse="false"
CompareValue="1900-01-01"
CompareType="GREATERTHANEQUALTO"/>
</Attribute>
<Attribute Name="name" Type="java.lang.String"/>
<MethodAccessor IsCollection="false" Type="long" id="userAge"
ReturnNodeName="Return">
<ParameterInfo id="fudgeFactor" Type="int" isStructured="false"/>
</MethodAccessor>
<ConstructorMethod IsCollection="false" Type="void" id="User"/>
</JavaBean>
14
1/19/2008
UserMsgBundle.java
package book.model;
import oracle.jbo.common.JboResourceBundle;
// ---------------------------------------------------------------------
// --- File generated by Oracle ADF Business Components Design Time.
// --- Custom code may be added to this class.
// --- Warning: Do not modify method signatures of generated methods.
// ---------------------------------------------------------------------
public class UserMsgBundle extends JboResourceBundle {
15
1/19/2008
Summary
• Creating Java class
– User.java
• Define the data controls
– The Data Control definition files:
• DataControls.dcx
• User.xml
– Data Controls Palette
• Enhance the data controls
– Add default values
– Control hint (field label & tooltips)
– Simple declarative validation
ADF Bindings;
Using the Data Control
16
1/19/2008
17
1/19/2008
firstPage.jsp
<af:panelForm>
<f:facet name="footer"/>
<af:inputText value="#{bindings.name.inputValue}"
label="#{bindings.name.label}"
required="#{bindings.name.mandatory}"
columns="#{bindings.name.displayWidth}">
<af:validator binding="#{bindings.name.validator}"/>
</af:inputText>
<af:selectInputDate value="#{bindings.birthday.inputValue}"
label="#{bindings.birthday.label}"
required="#{bindings.birthday.mandatory}">
<af:validator binding="#{bindings.birthday.validator}"/>
<f:convertDateTime pattern="#{bindings.birthday.format}"/>
</af:selectInputDate>
</af:panelForm>
18
1/19/2008
firstPage.jsp
• You will notice expression beginning with
“#{bindings.”
• You will also see references to validator
and a converter (f:convertDateTime) which
refer to these expression using ‘binding’
object
19
1/19/2008
20
1/19/2008
<executables>
<iterator id="UserDataControl_rootIter" RangeSize="10"
Binds="root“ DataControl="UserDataControl"/>
</executables>
<bindings>
<attributeValues id="name" IterBinding="UserDataControl_rootIter">
<AttrNames>
<Item Value="name"/>
</AttrNames>
</attributeValues>
<attributeValues id="birthday“ IterBinding="UserDataControl_rootIter">
<AttrNames>
<Item Value="birthday"/>
</AttrNames>
</attributeValues>
</bindings>
</pageDefinition>
21
1/19/2008
firstPage.jsp
<af:panelForm>
<f:facet name="footer"/>
<af:inputText value="#{bindings.name.inputValue}"
label="#{bindings.name.label}"
required="#{bindings.name.mandatory}"
columns="#{bindings.name.displayWidth}">
<af:validator binding="#{bindings.name.validator}"/>
</af:inputText>
<af:selectInputDate value="#{bindings.birthday.inputValue}"
label="#{bindings.birthday.label}"
required="#{bindings.birthday.mandatory}">
<af:validator binding="#{bindings.birthday.validator}"/>
<f:convertDateTime pattern="#{bindings.birthday.format}"/>
</af:selectInputDate>
</af:panelForm>
<bindings>
<attributeValues id="name" IterBinding="UserDataControl_rootIter">
Refer to section
<AttrNames> <executables> in the
<Item Value="name"/> same file
</AttrNames>
</attributeValues>
<attributeValues id="birthday“ IterBinding="UserDataControl_rootIter">
<AttrNames>
<Item Value="birthday"/>
</AttrNames>
</attributeValues>
</bindings>
</pageDefinition>
22
1/19/2008
#{bindings.birthday.inputValue}
• bindings : data managed by ADFm
• birthday : attribute mapped in Page
Definition file
• inputValue : actual data of the attribute in
runtime.
• Format:
#{bindings.MyBindingObject.propertyName.attributeName}
23
1/19/2008
24
1/19/2008
Contents
• ADF Bindings
– Bindings (Most cases we are interested in data listed
under this node, it contain the available data in the
context of the current page)
– Data (use to access the bound data element of any
page within application)
• JSF Managed Beans
– Contain managed bean
• JSP Objects
– General expression scope available in JSPs, such as
sessionScope, coookies etc.
25
1/19/2008
09: <dataControlUsages>
10: <dc id="UserDataControl" path="book.model.UserDataControl"/>
11: </dataControlUsages>
12: </Application>
Web.xml
<context-param>
<param-name>CpxFileName</param-name>
<param-value>viewcontroller.DataBindings</param-value>
</context-param>
26
1/19/2008
Summary
• Creating JSF page
– firstPage.jsp
• Binding File
– DataControl.dcx : define data controls
– firstPagePageDef.xml : define binding used on a
particular page
– DataBinding.cpx : define the relationship between
PageDef files and page file (jsf). It also define the
data controls used within the project.
• Reference to DataBinding.cpx
– Web.xml
Review of files
Description Files Notes
Java class/EJB User.java
Data Control Definition User.xml Describe User.java. Each java class will
have it’s own <filename>.xml
DataControls.dcx Index file for all data control. Only one dcx
file for each project folder.
JSP/JSF firstPage.jsp
Page Definition firstPagePageDef.xml Contain data required for the jsp file
Binding master file DataBindings.cpx Master mapping to associate jsp file with
page definition file
Others web.xml Defining the name & location of the
DatBinding.cpx
27
1/19/2008
Dialog box
Dialog box Notes
28