Beruflich Dokumente
Kultur Dokumente
Objectives
After completing this lesson, you should be able to do the following: Describe how data binding and the JavaServer Faces (JSF) page life cycle interact Define listeners and custom controllers to augment the ADFm life cycle Explain how the Application Development Framework (ADF) life cycle works
6-2
Agenda
JSF Life Cycle ADF Faces Life Cycle JSF and ADF Faces Life Cycle
6-3
6-4
6-5
The JSF life cycle phases use a UI component tree to manage the display of the Faces components. (f:view is the root component of this UI tree.) The FacesServlet object manages the requestprocessing life cycle in JSF applications. FacesServlet creates an object called FacesContext.
Copyright 2008, Oracle. All rights reserved.
Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response
6-6
Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response
The JSF components are retrieved from the JSF context. Component values are updated with the values in the request parameter. If a components immediate property is set to true, conversion and validation occur within this step, and value change events fire.
6-7
Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response
6-8
Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response
Until this step, the request only updated the components, setting their submittedValue property.
Now, the model (managed beans or in the ADF case, the binding container) is updated with the validated values.
6-9
Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response
The Invoke Application phase manages any forms that the page submits and executes any business logic. It also processes any action events that are fired and evaluates any navigation actions that need to execute.
6 - 10
Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response
6 - 11
The developer has the option to short-circuit the JSF life cycle:
A ValueChangeEvent runs before validation is performed. Use ValueChangeListener to call the Render Response phase. Update the model manually only if needed. Use case: Cancel button that should navigate to another page without submitting the data
6 - 12
Agenda
JSF Life Cycle ADF Faces Life Cycle JSF and ADF Faces Life Cycle
6 - 13
Use custom JavaScript-based converters and validators that run on the page without a server round trip. Client-side validation triggers validation of the appropriate form or subform when a specific client event is queued.
6 - 14
6 - 15
Agenda
JSF Life Cycle ADF Faces Life Cycle JSF and ADF Faces Life Cycle
6 - 16
Uses the binding container to make data available during the current page request
6 - 17
JSF Apply Request Values JSF Process Validation JSF Update Model Values
Prepare Render
Update Model Values Validate Model Updates Invoke Application JSF Invoke Applications
Changed View?
yes
no
Render Response
6 - 18
Initialize Context:
6 - 19
6 - 20
Process Validations:
Local values of components are converted and validated on the client. If there are errors, the life cycle jumps to the Render Response phase. Exceptions are also caught by the binding container and cached.
JSF Process Validations: This phase provides the before and the after phase events.
Copyright 2008, Oracle. All rights reserved.
6 - 21
JSF Update Model Values: This phase provides the before and the after phase events. Validate Model Updates:
The updated model is now validated against any validation routines set on the model. Exceptions are caught by the binding container and cached.
6 - 22
Initialize Context:
Initialize the context if navigation occurs. Initialize the page definition file for the next page.
Render Response: This phase prepares the returning values to be displayed. JSF Render Response: This phase provides the before and the after phase events.
Copyright 2008, Oracle. All rights reserved.
6 - 23
Task Flows
Are an extension to the JSF standard page flow engine Address some key enterprise requirements:
Page reuse Executing code in a flow (task flow, not page flow) Security Flow control Exception and transaction management
Are defined using a page flow diagram (similar to JSF but with more components) Also allow the definition of managed beans (similar to facesconfig.xml)
6 - 24
Router
It evaluates an Expression Language (EL) expression and returns an outcome based on the value of the expression.
6 - 25
View
Displays a JSF page or page fragment. Multiple View activities can represent the same page or same page fragment.
6 - 26
6 - 27
View scope: The object is available until the view port ID for the current view activity changes.
6 - 28
Page A
Page B
Page C
Page D
Page E
Request
ViewScope
PageFlow
Backing Bean
Session
Application
6 - 29
About Regions
Page Region A region is a UI p1.jsff p2.jsff component whose p3.jsff content is based on a task flow definition. When first rendered, the regions content is that of the default view activity in the task flow. Any view activity used in the region must be created using page fragments, not pages. A page fragment is:
A JSF JSP document that can be rendered as content of another JSF page Similar to a page, except that it cannot contain elements such as <f:view>
6 - 30
If the variable bindings is used within the EL expression, the context refers to the binding container of the parent page.
Copyright 2008, Oracle. All rights reserved.
6 - 31
RefreshCondition expression: Boolean expression, which controls whether the executable should fire at all
6 - 32
Summary
In this lesson, you should have learned how to: Describe how data binding and JSF Page life cycle interact Define listeners and custom controllers to augment the ADFm lifecycle Explain how the ADF life cycle works
6 - 33
6 - 34