adf mobile : data services java beans...• add providerchangesupport calls as needed • similar...
TRANSCRIPT
![Page 2: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/2.jpg)
Overview
Topics covered in this lesson include:
• Roadmap and Best Practices
• Data Services Overview
• Data Objects and “CRUD” Objects
• Data Relationships Definition
• Data Change Events
• Bean Data Controls and Exposing Data to UI
![Page 3: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/3.jpg)
Roadmap for Defining Java Bean
Data Services
• Identify Application Data Requirement
• Data Objects
• Data Relationship
• CRUD (Create/Read/Update/Delete) Operations
Requirement
• Implement Java Beans (POJOs) to support Data
Objects and CRUD operations
• Expose Java Beans as Bean Data Controls
• Bean Data Controls can then be used to
construct the user interface
![Page 4: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/4.jpg)
Best Practices for Data Services
and Application Development
• Always understand data processing requirement
before implementing Data Services
• Start with implementing Java Beans that
implement Data Objects and support CRUD
operations
• Populate the Data Objects initially with local/stub
data specified within the Java Beans
• So that client application can be developed in parallel
with server-side logic
• Test and enhance ADF Mobile application
iteratively using stub data
![Page 5: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/5.jpg)
ADF Mobile Data Services
Overview
Device Native Container
Web ViewADF Mobile
AMX View
Java VMJava Beans
Data Controls
Mobile Device
REST (JSON) Services
HTML5 & JavaScript
ADF Controller
Local Data Server
REST (XML w/ XSD) Services
SOAP Web ServicesLocal HTML
![Page 6: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/6.jpg)
Beans and Data Controls Types
Device Native Contaier Java VMJava Beans
Data Controls
• Data Controls – exposes
data to User Interface:
• Bean Data Controls
• Web Services Data Controls
• URL Data Controls
• Java Beans
• Data Objects and “CRUD” Objects: contains core
application logic to process data
• Managed Beans: Invoked by user interface/AMX page
to perform UI related functions
• This lesson focuses on Bean Data Control, Data
Objects, and “CRUD” Objects
![Page 7: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/7.jpg)
Embedded Java Virtual Machine
• ADF Mobile container embeds a light-weight, “headless”
Java Virtual Machine
• Headless = no UI library as ADF Mobile leverages HTML5-
based UI
• Based on Java version 1.4
• No generics support such as typed collections like set<string>
• No annotation support
• Additional links/documentation on JVM:1. CDC API comparison chart:
http://www.oracle.com/technetwork/java/cdc-packages-150013.pdf
(See especially column for "FP 1.1 JSR 219" which is the same as the ADF
Mobile’s embedded JVM)
2. Javadoc of APIs in CDC/Foundation Profile Libraries:
http://docs.oracle.com/javame/config/cdc/ref-impl/fp1.1.2/jsr219/index.html
![Page 8: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/8.jpg)
Java Bean Data Services
• Two types of POJOs need to be developed to process
data:
• Data Objects:
• Represents a Data Object (e.g. Employees)
• Define attributes and types for each data object
• Contain getter/setter for the attributes
• Represent data object hierarchical relationships
• “CRUD” Objects:
• Instantiate and populates Data Objects
• Support CRUD (Create/Read/Update/Delete) operations
• Access web services or local database
• Expose data access methods to UI via Bean Data Control
![Page 9: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/9.jpg)
Data Objects Definition
• Typically one Java class per data object
• Steps to create data object to hold data
• Create a Java Class
• Declare and initialize data attributes as variables
• Generate Accessors through context menu
• Check “Notify Listener when Property Changes” to add
data change listeners to propagate changes to UI
• This adds propertyChangeSupport APIs to all the “SET”,
“ADD”, and “REMOVE” methods in the Data Object
• Propagate attribute value changes to the user interface
![Page 10: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/10.jpg)
“CRUD” Objects Definition
• Expose methods for CRUD operations
• Data may reside in CRUD object itself, flat files, local
database, and/or web services
• Instantiate and populate one or more Data
Objects
• May contain additional Property and Provider
Data change notification logic
![Page 11: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/11.jpg)
Steps to Create “CRUD” Objects
• Declare one or more collections to hold data
within the “CRUD” Object
• In the Constructor,
• Instantiate the list variable (for example as ArrayList)
• Invoke data population logic here if you wish to load
data whenever the CRUD Object is instantiated
• In the “GET” or data retrieval method
• Convert the ArrayList into an Array of Data Objects and
return data
![Page 12: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/12.jpg)
Steps to Create “CRUD” Objects
• Implement additional methods to retrieve or
update data• For example, a “READ” method that calls a web services to
retrieve a list of employees from a department
• Another example, a “UPDATE” method that updates a field in
the local SQLite DB
• Add providerChangeSupport calls as needed
• Similar syntax as propertyChangeSupport calls in the
Data Objects
• Stocktracker sample app contains examples of this call
• Implement any additional methods
• For example, returning employee count, etc.
![Page 13: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/13.jpg)
Define Data Object Relationships
• Define data relationships by creating multiple
layers of Data and ”CRUD” Objects
• For example, in the simple HR example:
• A department (“Parent” data object) contains several
employees (“Child” data object)
• Employees: Data Object for Employees
• Departments: Data Object for Departments
• EmployeeList: “CRUD” Object that returns a list of
employees
• DepartmentList: “CRUD” Object that returns
departments and employees
![Page 14: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/14.jpg)
Department “CRUD” Objects
• Declare a list for Department and declare/instantiate the
EmployeeList “CRUD” Objects
QLite database
• EmployeeList may be populated on instantiation if data is
populated in the constructor, or add a method that invokes
EmployeeList’s GET Method to populate data
public class DepartmentList {
private static List s_departments = null;
private static EmployeeList s_employees = new
EmployeeList();
![Page 15: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/15.jpg)
Department “CRUD” Objects
• Implement additional methods to retrieve data – for
example get employees by department ID
public Employee[] getEmployeesByDept(int deptId) {
ArrayList reports = new ArrayList();
Employee[] emps = s_employees.getEmployees();
for (int x = 0; x < emps.length; x++) {
Employee e = emps[x];
if (e.getDeptId() == deptId) {
reports.add(e);
}
}
return (Employee[])reports.toArray(new Employee[reports.size()]);
}
Note the code that converts ArrayList to Array
![Page 16: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/16.jpg)
ArrayList & Array of Data Objects
• Use ArrayList to hold data when populating and
processing data
• Much more flexible than an Array[ ] as array size
is fixed during creation and data needs to be
assigned to a specific location (array[1])
• Supports methods like
(add/remove/contains/size/get) that allows data to
be easily processed/searched/etc.
• Convert ArrayList to Array of Data Object when
returning data
• Data needs to be returned as an Array of Data
Objects, as required by ADF Mobile internals
![Page 17: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/17.jpg)
Propagate Data Change Events to
User Interface• When data is changed in Java, you must fire a
data change event listener to propagate changes
to bindings and user interface
• Methods are automatically generated when
checking ”Notify Listener When Property Changes”
when generating accessors for the POJOs
• Additional calls are also needed whenever data
change event needs to be propagated
![Page 18: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/18.jpg)
Different Data Change Events and
Corresponding Listeners
• PropertyChangeListener: Invoke to propagate
an attribute value change
• Supports firePropertyChange, firePropertyDelete,
and firePropertyCreate
• propertyChangeSupport.firePropertyChange(“firstName"
, oldFirstName, newFirstName);
• ProviderChangeListener: Invoke to propagate
changes in a data collection/object
• Supports fireProviderChange, fireProviderRefresh,
fireProviderDelete, and fireProviderCreate
• propertyChangeSupport.firePropertyCreate(“perso
ns", personID, personDataObject);
![Page 19: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/19.jpg)
Exposing POJOs to User Interface
• Right (Ctrl) Click on
the “CRUD” Data
Object
• Create Bean Data
Control
• Modify datacontrols.dcx for
data control attributes,
hints, validation rules,
etc.
![Page 20: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/20.jpg)
Modify Data Control Details
1. Modify the DataControls.dcx file – Attribute tab only
2. Set Default Value, Key (to support any Key operation) ,
UI Hints, and Validation Rules (Compare, Length, List,
and Range only)
![Page 21: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/21.jpg)
Use Data Controls on Page
• Data Controls have
been created
• Drag and Drop onto
page, just like with
Web Based ADF
• Modify as needed
![Page 22: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/22.jpg)
•<Insert Picture Here>
Summary
Topics we covered in this lesson were:
• Roadmap and Best Practices
• Data Services Overview
• Data Objects and “CRUD” Objects
• Data Relationships Definition
• Data Change Events
• Bean Data Controls and Exposing Data to UI
![Page 23: ADF Mobile : Data Services Java Beans...• Add providerChangeSupport calls as needed • Similar syntax as propertyChangeSupport calls in the Data Objects • Stocktracker sample](https://reader030.vdocument.in/reader030/viewer/2022040822/5e6c662f237ce6437d354d17/html5/thumbnails/23.jpg)
<Insert Picture Here>
Learn More
• Oracle.com/technology/jdev
• Download
• Tutorials
• Discussion forum
• Samples
• ADF Developer Guide
• More…