Title: Oracle WebCenter Suite Technical Training JDeveloper, JSF and Oracle ADF review
1Oracle WebCenter Suite Technical
TrainingJDeveloper, JSF and Oracle ADF review
2Agenda
ltInsert Picture Heregt
- Oracle JDeveloper
- Introduction to Java Server Facesand ADF Faces
- Review of Oracle ADF concepts
3Oracle JDeveloper
JDeveloper is a Java IDE
Java
4Oracle JDeveloper
- Developers need an IDE
- with advanced editing functions
- with advanced coding function (eg refactoring)
- with full support for all (java) industry
standards - with modeling support
- with debugging and profiling support
- a toolbox for Java, XML, SQL, BPEL,
- with version control support
Java J2EE specification
J2EE XML services and apis servlet, jsp, ejb,
jdbc, jms, jts, etc.
Java
5Oracle JDeveloper
- Developers need an IDE
- with advanced editing functions
- with advanced coding function (eg refactoring)
- with full support for all (java) industry
standards - with modeling support
- with debugging and profiling support
- a toolbox for Java, XML, SQL, BPEL,
- with version control support
- that helps, without taking away control from
developer
Java J2EE specification
J2EE XML services and apis servlet, jsp, ejb,
jdbc, jms, jts, etc.
Java
6Oracle JDeveloper
but how do I build an application ?
Java J2EE specification
J2EE XML services and apis servlet, jsp, ejb,
jdbc, jms, jts, etc.
Java
7Oracle JDeveloper
application code
infrastructure code
your code Java J2EE specification
J2EE XML services and apis servlet, jsp, ejb,
jdbc, jms, jts, etc.
Java
8Oracle JDeveloper
application code
infrastructure code
- Developers need an IDE
- with more than advanced editing functions
- that helps, without taking control away from
developer
J2EE XML services and apis servlet, jsp, ejb,
jdbc, jms, jts, etc.
Java
9Oracle JDeveloper
- JDeveloper is a Java IDE
- that helps creating components,
- support the latest standards (JDK5, EJB3, JSF,
BPEL, ) - AND
- helps creating applications
- without taking away the control from the
developer
10Agenda
ltInsert Picture Heregt
- Oracle JDeveloper
- Introduction to Java Server Facesand ADF Faces
- Review of Oracle ADF concepts
11What is JSF?
- Developed through Java Community Process (JCP) as
JSR-127 - Nickname Faces
- Goal Simplify creation of Java server GUIs
- Started May 2001
- First release March 2004
- Oracle is a primary contributor
12JSF Technology
- A basic JSF application consists of
- JSF UI components - encapsulated in JSP tag
libraries - Navigation Model defines rules for navigation
- Managed Beans - facilitate the UI logic of the
application - Helper Objects Validation and conversion
13JSF Architecture
Controller
14Navigation
- JavaServer Faces uses its own controller for page
navigation - NavigationHandler evaluates navigation case and
routes to new page - Supports page forward and page re-directs
- Navigation Cases
- Basic Navigation
- Based on static string outcome
- Based on dynamic outcome
- Navigation as the result of an action
- Navigation cases can be defined based on the
method returning the outcome string
15How Navigation Targets are Determined
- Pluggable class that handles navigation
- Navigation is based on navigation cases defined
in faces-config.xml - Determine ltfrom-viewgt element to use
- Exact ViewId match (/app/public.jsp)
- Wildcard ViewId match (/app/)
- Default ViewId match ()
- Determine navigation to case lookup
- elements specifying both from-action and
from-outcome - elements specifying only from-outcome
- elements specifying only from-action
- elements where both elements are null
16Basic Navigation
- Navigation cases are defined in faces-config
file -
- Dynamic navigation
- Static navigation
ltnavigation-rulegt ltfrom-view-idgt/app/staff/SRS
earch.jspxlt/from-view-idgt ltnavigation-casegt
ltfrom-outcomegtViewlt/from-outcomegt
ltto-view-idgt/app/SRMain.jspxlt/to-view-idgt
lt/navigation-casegt lt/navigation-rulegt
public String drillDown_action() return
"View"
17About Managed Beans
- Managed beans are optional and can be used to
- Store state (e.g. information about the
authenticated user) - Execute Java routine, e.g. on button pressed
- Define handler for Event Listeners
- Managed beans ? Backing Beans
- Backing beans contain getter/setter methods for
UI components
18Managed Beans
- Configured in faces-config.xml
- Plain Old Java Objects (POJOs), Lists and Maps
- Access scope
- None
- Request
- Application
- Session
- Have no-argument constructor
- Lazy initialization by JavaServer Faces framework
"as needed"
19Creating Managed Beans
1. Double click on command button and select
backing bean or choose to createnew managed bean
2. Browse for existing Java class or create new
class
3. Search class
5. Create method
4. Select class
6. Bean automatically gets configured In
faces-config.xml
20Configuring Managed Beans
- Entry in faces-config.xml
ltmanaged-beangt ltmanaged-bean-namegtUserbeanlt/man
aged-bean-namegt ltmanaged-bean-classgtcom.oracle.
sample.Userlt/managed-bean-classgt
ltmanaged-bean-scopegtrequestlt/managed-bean-scopegtlt
/managed-beangt
21Referencing Managed Beans
- Use from Expression Language in JSF Page
- Use from Java code
lthinputText value"Userbean.firstName"/gt
FacesContext ctx FacesContext.getCurrentInstance
() Application app ctx.getApplication() Value
Binding bind app.createValueBinding(Userbean
) Object o bind.getValue(ctx) User user
(User) o
22Managed Properties
- Managed bean variables that are exposed through
getter and setter method - Configured in faces-config.xml
- Possible values
- Null
- Literal string
- Lists and Maps
- Value binding expression (EL)
23Managed Properties Examples
- Literal String
-
- EL accessing Managed Bean
ltmanaged-beangt ltmanaged-propertygt
ltproperty-namegtlabellt/property-namegt
ltvaluegtHello Worldlt/valuegt lt/managed-propertygt
ltmanaged-beangt ltmanaged-propertygt
ltproperty-namegtlabellt/property-namegt
ltvaluegtUserbean'firstname'lt/valuegt
lt/managed-propertygt
24About Backing Beans
- Backing Beans are Managed Beans, but Managed
Beans are not necessarily Backing Beans - JavaBeans that are associated with (bound to) UI
components in a page - Can be used to programmatically modify properties
on UI components - Can have methods defined that associate
functionality with components, e.g. - Validation
- Event handling
- Navigation
25About Converters
- All web input and output is a string
- Converters translate objects into strings and
vice versa - Values that cannot be converted cause an error
message - Standard errors are defined and can be overridden
- Converters can be used as programmatic format
masks - If no converter is explicitly defined for a
component, the JSF framework will select one.
Basic converters used in such a cases are
26Passing Values Between Pages
- Directly accessing a page definition from another
page using EL - Not considered best practices
- Creates inter-page dependencies
- Ability to do so might go away in the future
- Using parameters
- session scope
- request scope
- application scope
- Use Managed Bean properties
27Setting Session Scope Parameters
1
2
3
28Reading Session Scope Parameters
- Create variable on target page
- Reference session scope parameter through EL
- Reference variable from binding (e.g.
findDepartmentById)
29ADF Faces
- Built on top of JSF APIs
- Deployable on any compliant implementation of JSF
- Provides much of what is missing in JSF 1.1
- The component set is small
- No client-side behavior
- No support for customization
- Little direct support for working with databases
- Tools will of course support JSF but how well?
30What ADF Faces brings to JSF
- Much larger component set
- Over 100 types of components
- Far more advanced and interesting components
- Partial-page rendering, etc.
- Rich feature set for customizing applications
- ADF model support out-of-the-box
31JSF Components
32ADF Faces Components
33Client-side validation
- A major missing feature of JSF
- Struts Validator supports it
- ADF Faces does too
- Server- and client-side validation/conversion
from the same code - Use standard JSF converters and validators
- (But you have to use our input components)
34ADF Faces Converters
- Converters provided by ADF Faces in addition to
the JavaServer Faces converters - ColorConverter
- Converts string values to colors and vice versa
- Uses RGB value codes
- DateTimeConverter
- Converts an strings to and from java.util.Date
objects - Supports timezones through settings in
adf-faces-config.xml. Timezone defaults to GMT - NumberConverter
- Extends JavaServer Faces NumberConverter
functionality
35Partial Page Rendering
- PPR ? AJAX
- Update the page without refreshing the whole page
- Common Examples
- LOV dialog call pop-up LOV, return selected
value into calling page - Scrolling through a results table
- Expanding a tree control
36Partial Page Rendering
- Much PPR in ADF Faces is transparent
- Expanding a tree node
- Nothing special needs to be done
- Explicit PPR attributes
- partialSubmit Used by commandItems
- autoSubmit used by input items / lists etc.
- partialTriggers all components
37PPR - partialSubmit
- Lets a commandItem execute server code without
posting the whole page - In this case to pop up an informational page
ltafcommandLink text"FAQ"
action"dialogFAQ"
useWindow"true"
partialSubmit"true"/gt
38PPR - autoSubmit
- For a valueHolder such as a inputText or
checkbox, posts the change to the server as soon
as it is made e.g on navigation outor
selection - Common uses
- Changing the UI based on a field value
- Instant validation
ltafselectOneChoice value"bindings.ServiceReque
ststatus.inputValue"
label"bindings.ServiceRequeststatus.label"
autoSubmit"true"
id"status"gt
39PPR - partialTriggers
- Refresh this item if that item changes / submits
- Includes extra UI elements in the PPR process
that "need to know" about the change - e.g. If the value of field a changes to "X"
disable this field. - partialTriggers attribute lists component ids
that the component is "watching" - A single component can watch multiple components
- Multiple components can watch a single component
- Caution sometimes the parent container has to
watch not the component itself e.g. menus
40PartialTriggers example
- Enable / disable date input when selectOneChoice
value changes - Disabled is re-evaluated when selectOne changes
ltafselectInputDate value"bindings.assignedDat
e.inputValue"
label"bindings.assignedDate.label"
partialTriggers"status"
binding"backing_SREdit.assignedDate"
disabled
"bindings.ServiceRequeststatus.inputValue2
" validator"backing_SREdit
.assignedDateValidator"gt
41Agenda
ltInsert Picture Heregt
- Oracle JDeveloper
- Introduction to Java Server Facesand ADF Faces
- Review of Oracle ADF concepts
42Oracle ADFin one slide
UI and Controller technology
43Framework-based J2EE development Oracle ADF in
another slide -)
- Glue Between the View and the Business Service
- Consistent data binding
- JSR-227 A Standard Data Binding Data Access
Facility for J2EE
BusinessComponent
Web Service
TopLink
Model
EJB
JavaClass
44Framework-based J2EE development Drag and drop
data binding
- Data Control Palette
- Expose any business service
- Available to any client
45Framework-based J2EE development UI Development
- Visual editors
- JSP and HTML
- JavaServer Faces
- Swing (ADF JClient)
- Component palette
- Common binding
- Property inspector
- Structure pane
46JSF Architecture
Renderer
UI Component
Expr. Language
- UIComponent is rendered through Renderer class
- Expression Language Value Binding is used to
access managed bean also know as a "backing bean" - Managed bean accesses J2EE persistence layer
Managed bean
JSF Page
J2EE Persistence Layer / JDBC
RDBMS
47JSF Architecture with ADF
Renderer
UI Component
Expr. Language
- EL accesses bindings object to value bind UI
components - ADF bindings object is set through ADF Filter
in web.xml - Bindings object accesses ADF Binding container,
which then accesses DataControl - Business Services provide access to various data
sources
ADF bindings Object
JSF Page
ADF Binding
ADF DataControl
BusinessService 3
BusinessService 2
BusinessService 1
XML
URL
RDBMS
WS
48ADF Binding
- JavaServer Faces pages can create value bindings
to the ADF binding container using EL accessing
the bindings object - The bindings object is created by the ADF
servlet filter that is defined in the web.xml
file - The ADF servlet filter is mapped to .jsp and
.jspx file types - Bindings object needs to be configured as a
managed property before it can be used in Managed
Beans
bindings.firstName.inputValue
49Configuring ADF Binding Access for Manage Beans
- Create Managed Propertyand set value to
bindings - In Managed Bean, create instance variable with
same name as managed property - Make sure variable type is oracle.binding.BindingC
ontainer - Create setter and gettermethod for instance
variable - Binding is automatically configured on
declarative method binding creation
50Setting/Getting Bound Data
- Accessing the value of a CoreSelectOne ADF Faces
list based on the returned selected index
01. CoreSelectOneChoice singleSelectItem
(CoreSelectOneChoice)
valueChangeEvent.getSource() 02. int
SelectedIndx ((Integer) singleSelectItem.getValu
e()).intValue() 03. DCIteratorBinding iter
((DCBindingContainer)bindings).
findIteratorBinding("DepartmentsView1") 0
4. rw iter.getRowAtRangeIndex(SelectedIndx) 05.
valueToPrint "The selected value is
"rw.getAttribute("LocationId")
51Executing Methods in ADF
- Methods are defined in pageDef file as operation
bindings - Operation can be accessed and executed from ADF
Faces - EJBs use methods on the ADF binding for CRUD
01. OperationBinding operationBinding
(OperationBinding)bindings.getOperationBinding
("removeServiceHistory") 02. Map params
operationBinding.getParamsMap() 03.
params.put("serviceRequest", parentSvr) 04.
params.put("serviceHistory", shObjectToDelete) 05
. Object result operationBinding.execute()
52Execute Bound Methods on JSF Page Load
- Actions in the executable section are invoked on
page load - Actions bind to methods or actions in the
bindings definition - Condition on when action is executed can be
determined through EL
53ADF Binding Summary
View Project
DataControls.dcx
- web.xml sets up the ADFBindingFilter
- faces-config.xml used to register JSF application
resources - adf-faces-config.xml configures ADF
Faces-specific user interface features - adf-faces-skins defines custom look and feel
ltsession beangt.xml
ltbean namegt.xml
DataBindings.cpx
ltpagenamegtPageDef.xml
web.xml
faces-config.xml
adf-faces-config.xml
adf-faces-skins.xml
54ADF Binding Summary
Model Project
DataControls.dcx
ltsession beangt.xml
ltbean namegt.xml
View Project
DataBindings.cpx
ltpagenamegtPageDef.xml
web.xml
faces-config.xml
adf-faces-config.xml
adf-faces-skins.xml