don't reinvent the wheel - tips and tricks for rease in oracle adf - luc bors
DESCRIPTION
For ages we have known that reinventing the wheel is not a smart thing to do. However, we as software developers tend to do this all the time. In this session you will learn how to avoid this by taking advantage of the reuse capabilities of the ADF Framework. You will see how to create Page Templates and use them throughout your application instead of creating the same complex layout over and over again. Next you will see how to create a reusable skin to use in your applications. Finally you will see how to extend the ADF Component Library with your own reusable declarative components and reuse them throughout your application.TRANSCRIPT
![Page 1: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/1.jpg)
Luc Bors, june 2013, ODTUG KScope 2013 New Orleans
Tips and Tricks for UI Reuse in Oracle ADF
Don't Reinvent the Wheel
![Page 2: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/2.jpg)
Who Am I
• Luc Bors
• Principal Consultant
• AMIS Nieuwegein Netherlands
• Friends of Oracle & Java
• 5 Oracle ACE(D)
• Oracle Partner
![Page 3: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/3.jpg)
Topics
• Reuse – ADF Controller and Faces
– Page Templates
– Declarative Components
– Stylesheets
– Task Flows
![Page 4: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/4.jpg)
The (somewhat ugly)Sample Application
![Page 5: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/5.jpg)
Page Templates
• Specify the layout structure (of groups) of pages
– For example: top bar, side bar, footer
– Predefine placeholders for pages to inject their contents
• Page can be based on template
– It will provide the content for the placeholders (seen as facets)
– It can pass parameters to the template – for example for the title of the page or the
page bread crumb trail
![Page 6: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/6.jpg)
Page Templates
• Centrally specifying the overall structure and some of the look & feel for all or specific types of pages
• Can also be applied dynamically, depending on some context settings
– This allows a single page to be presented in different ways to different users or under
different conditions
– Templates allow different structure and component ordering for the same page
• Page Templates make maintenance of the overall layout structure much easier
![Page 7: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/7.jpg)
Page Templates
• Create a Page Template
– Embed one or more facetRef elements for the holes to be filled by the pages based on the template
– Publish the template “API” – the input parameters it supports
• Create pages based on the template
– In these pages, provide content for the facets exposed by the template
– Provide values for input parameters supported by template
• At any point in time:
– change the template (reusing same facetRefs and parameters)
– change the facet contents in any page
– change template ref in a page (to template with same facets)• Can be done dynamically
![Page 8: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/8.jpg)
Defining the template
![Page 9: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/9.jpg)
Building the Layout
![Page 10: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/10.jpg)
Using the Attributes
![Page 11: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/11.jpg)
The Template Definition
![Page 12: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/12.jpg)
The Template UI components
![Page 13: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/13.jpg)
Demo
![Page 14: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/14.jpg)
Custom Components
• Compose reusable ‘packages’ for frequently occurring combinations of ADF Faces/JSF components
– Declarative reuse for consistency and productivity
– Better encapsulation than page fragments
– Internally a declarative component is built out of a combination of JSF components
• Declarative components can be used like normal JSF components
– They expose a number of attributes (that are wired to attributes of the internal JSF
components)
– They may have facets (to embed other JSF components)
• Examples: LOV/DropDown Switcher, InputTime, Selection components for static domains, Button bars
![Page 15: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/15.jpg)
Custom Components
• Choose JSF Declarative Component in the New Gallery
• Specify the properties for the component
– Name, Package, TaglibName
– The attributes exposed to consumers of the components• And default values for the attributes
– Methods – name and signature – to use for method bindings
– Names of the facets that are published (and that will be used to embed JSF content
inside the declarative component)
• Create the content of the Component by assembling JSF components –much like you do for a Page Template
– Using facetRef components, #{attrs.<attrName>} and #{component.<methodName>}
![Page 16: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/16.jpg)
Create Custom Component
![Page 17: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/17.jpg)
Defining the Component
![Page 18: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/18.jpg)
Building the UI
![Page 19: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/19.jpg)
Demo
![Page 20: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/20.jpg)
Stylesheets
![Page 21: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/21.jpg)
Demo
![Page 22: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/22.jpg)
Overview
• Reusable components – Bounded Task Flows
– Multi page, isolated memory scope
– Controller and flow logic, executing business logic
– Interface with input parameters and output events
– Dynamically switching between regions
– Role based authorization
– Transaction management
– Savepoints and Rollback support
• Unbounded Task Flow
– Bookmarking, …
![Page 23: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/23.jpg)
Examples
![Page 24: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/24.jpg)
Create a Bounded Task Flow
![Page 25: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/25.jpg)
Taskflows
![Page 26: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/26.jpg)
Building a Reusable Task Flow Catalog
• Organizations may create a catalog of task flows
• Reusable services, encapsulated with clear interfaces
– Input parameters
– Result
– Events published
• Such task flows can also be published by
– Third parties
– ‘the community’
![Page 27: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/27.jpg)
Demo
![Page 28: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/28.jpg)
Reusing Reusables: ADF Libraries
• Sharing reusable assets
– Task Flows, Stylsheets, PageTemplates and Custom Components
– can be deployed and distributed through ADF Libraries (JAR files, design time)
– ADF Libraries are added to consuming applications
– When added, components from library can be reused in consuming application
![Page 29: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/29.jpg)
ADF Libraries
• ADF Library enables you to reuse components:
– Package them into ADF Library JAR files
– Add them to a reusable component repository
– Add the library to a project to use its components
![Page 30: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/30.jpg)
How does it work
• Deploy the project that contains the component(s) to an ADF Library JAR
– JDeveloper automatically adds the required Tag library for the declarative
component(s)
• Add the Library in consuming projects
– Via the Resource Palette
• Declarative components will show up on the Component Palette
– They are used like normal components with attributes, method bindings and facets
![Page 31: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/31.jpg)
Deployment Profile
![Page 32: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/32.jpg)
Library Deployment
![Page 33: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/33.jpg)
Using an ADF Library
![Page 34: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/34.jpg)
Libraries are added
![Page 35: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/35.jpg)
What do we have so far ?
• ADF Page Template
• ADF Custom Component
• ADF Style sheet
• ADF Taskflow
![Page 36: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/36.jpg)
Using the Template
![Page 37: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/37.jpg)
Setting attribute values
![Page 38: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/38.jpg)
Using the Stylesheet
![Page 39: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/39.jpg)
Using the Custom Component
![Page 40: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/40.jpg)
Using the Taskflow
![Page 41: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/41.jpg)
Setting up the region
![Page 42: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/42.jpg)
Refreshing the region
![Page 43: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/43.jpg)
Demo
![Page 44: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/44.jpg)
Lets make some Changes
• All Reusable components can be changed
• Will have immediate effect in the application
– After redeployment of the library
![Page 45: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/45.jpg)
Other Topic : Reuse in ADF BC
• Declarative Model Driven functionality
– Most Recently Used, UI Hints
– List of Values, Model Driven Query Form
• Entity Object Business Logic Group
• View Criteria
– Multiple faces on the same ViewObject
• Shared Application Module
– Reuse data across sessions
![Page 46: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/46.jpg)
Summary
• ADF Provides mechanisms for reuse
• Initial investment
• Payback time is later
• Considerations:
– Is it reusable ?
– Will I reuse it ?
• But also
– Modularity
– Maintainability
– Increased Productivity
![Page 47: Don't Reinvent the Wheel - Tips and tricks for rease in Oracle ADF - Luc Bors](https://reader034.vdocuments.site/reader034/viewer/2022052619/55540b5cb4c90544428b5300/html5/thumbnails/47.jpg)