Your SlideShare is downloading. ×
  • Like
  • Save
Silicon Valley Code Camp - JSF Controller for Reusability
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Silicon Valley Code Camp - JSF Controller for Reusability


This session provides an overview of the JSF-based controller on ADF 11g - the ADF Controller. The session provides an overview of the extensions implemented by Oracle to the standard JSF controller …

This session provides an overview of the JSF-based controller on ADF 11g - the ADF Controller. The session provides an overview of the extensions implemented by Oracle to the standard JSF controller that make the ADF Controller.

Published in Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • Develop Applications with Oracle ADF 16 - JSF Life Cycle The life cycle of a JavaServer Faces page is similar to that of a JSP: The client makes an HTTP request for the page, and the server responds with the page translated to HTML. However, because of the extra features that JavaServer Faces technology offers, the life cycle provides some additional services to process a page. A JavaServer Faces page is represented by a tree of UI components, called a view. This tree is a run-time representation of a JSF page. Each UI component tag in a page corresponds to a UI component instance in the tree. The FacesServlet object manages the request processing lifecycle in JSF applications. FacesServlet creates an object called FacesContext , which contains the information necessary for request processing, and invokes an object that executes the lifecycle. When a client makes a request for the page, the life cycle starts. During the life cycle, the JSF implementation must build the view while considering state saved from the previous postback. When the client performs a postback of the page, the JavaServer Faces implementation performs several tasks, such as validating the data input of components in the view and convertin input data to types specified on the server side. The JSF implementation performs all of these tasks as a series of steps in the life cycle.
  • Develop Applications with Oracle ADF 16 - Coordination of JSF and ADF Lifecycles When a page is submitted and a new page requested, the application invokes both the JSF request lifecycle and the ADF page lifecycle. The JSF lifecycle handles the submission of values on the page, validation for components, navigation, and displaying the components on the resulting page and saving and restoring state. The JSF lifecycle phases use a UI component tree to manage the display of the faces components. This tree is a runtime representation of a JSF page: each UI component tag in a page corresponds to a UI component instance in the tree. The FacesServlet object manages the request processing lifecycle in JSF applications. FacesServlet creates an object called FacesContext , which contains the information necessary for request processing, and invokes an object that executes the lifecycle. The ADF lifecycle handles preparing and updating the data model, validating the data at the model layer, and executing methods on the business layer. The ADF lifecycle uses the binding container to make data available for easy referencing by the page during the current page request. The ADF lifecycle also contains phases that are defined simply to notify ADF lifecycle listeners before and after the corresponding JSF phase is executed (that is, there is no implementation for these phases). This allows you to create custom listeners and register them with any phase of both the JSF and ADF lifecycles, so that you can customize the ADF page lifecycle if needed, both globally or at the page level.
  • Using URL View Activites To display the resource, you must specify an EL expression that is evaluated at run-time to generate the URL to the resource. In addition, you can specify EL expressions that, when evaluated, are added as parameters and parameter values to the URL. A URL view activity redirects the client regardless of the view port (root view port or an ADF region) from which it is executed. The <redirect> element of a view activity performs in a similar way, except it can be used only if the view activity is within the root view port.
  • Bookmarking View Activities You can enable users to easily return to a view activity in an unbounded task flow by designating the activity as bookmarkable. On the Bookmark tab of the Property Inspector you can set the bookmark property to true . You can optionally add parameters in the URL Parameters section and can add an optional method binding in the converter field for a parameter’s value. You can also optionally specify a method in the method field that the ADF Controller should invoke before rendering the view. You could use this method to retrieve additional information based on the parameter values. Instead of making the view activity bookmarkable, you may choose to use the redirect option to create a new browser URL for the view activity. You do this by setting the redirect property to true on the Common tab of the Property Inspector for the view activity.
  • Passing Parameters to an ADF Bounded Task Flow A called ADF bounded task flow can accept input parameters from another ADF unbounded or bounded task flow and can pass return values to the caller upon exit. You can specify on the input parameter definition for the called bounded task flow whether an input parameter is required. If a required input parameter is not received, a runtime error occurs. An input parameter definition that is identified as not required can be ignored during task flow call activity creation.
  • Reentering an ADF Bounded Task Flow To deal with cases in which the end user clicks the back button to navigate back into an ADF bounded task flow that was already exited, you can specify task-flow-reentry options for the task flow definition. These options specify whether a page in the calling ADF bounded task flow can be reentered. Upon reentry, ADF bounded task flow input parameters are evaluated using the current state of the application, not the application state existing at the time of the original ADF bounded task flow entry.


  • 1.  
  • 2. Extending the JSF Controller for Reusability Juan Camilo Ruiz Principal Product Manager JDeveloper Team
  • 3. The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 4. Agenda
    • Back to basics
    • What is Task Flow?
    • Essential concepts
    • The really cool stuff
  • 5. Overview of JSF Page Life Cycle
      • A JSF page is represented by a tree of UI components, called a view.
      • Request processing is managed by FacesServlet , which creates FacesContext object.
      • When a client makes a request for the page, the life cycle starts.
      • During the life cycle, JSF implementation builds the view while considering state saved from the previous postback.
      • When the client performs a postback of the page, JSF implementation must perform life-cycle steps:
        • Conversion
        • Validation
  • 6. <Insert Picture Here> Controllers What and Why?
  • 7. How to get to the Opera? You Are Here Opera The Rules
    • Line 6 doesn't operate on Sundays
    • You have 30 minutes to get there in time
    • You have to meet a friend first to get the tickets
    • You must get your evening dress from the laundry (closes at 5 pm)
    • Train staff announced to go on strike at 6 p.m
    • Train tickets can only be reimbursed if not used
    • Day passes allow you to get on and off trains as often as you want
  • 8. It’s all about maintenance…
    • Without a web controller page links are hardcoded
    • For example:
    • Then we have a change:
    <a href=“orderLines.jsp&quot;> customer.jsp orderLines.jsp customer.jsp orderLines.jsp orderSelect.jsp <a href=“orderSelect.jsp&quot;> <a href=“orderLines.jsp&quot;>
  • 9. Web Controllers provide an Abstraction
    • We deal with named targets or events
    • Changing flow no longer requires page changes
    • Controller metadata defines how to handle the event
    showOrder customer.jsp orderLines.jsp customer.jsp orderLines.jsp orderSelect.jsp showOrder showOrderDetail
  • 10. <Insert Picture Here> ADF Controller
  • 11. ADF Controller
    • ADF controller (ADFc) extends and supersedes JavaServer Faces navigation model
    • Task flows define and process user navigation
      • Ideally suited for reuse and to partition application development
    • Metadata driven
    • Key concept and core knowledge in Oracle ADF
      • you can survive up to 10 days without water but you won't last more than a day without task flows
  • 12. ADF Controller Responsibility
    • Peform application navigation across browser pages and within browser pages
    • Navigate between activities and task flows and maintain controller state
    • Execute controller logic and custom methods during navigation
    • Manage task flow instance
  • 13. ADF Controller Benefits
    • Additional memory scopes
      • Avoid memory attribute name conflicts
      • Avoid memory bloating
    • Improved and declarative exception handling
    • Supports traditional web navigation model and rich internet navigation models
    • Support for nested control flows
    • Configurable order of Phase Listener execution
    • Save points for undo and failure recovery
  • 14. JSF and ADF Lifecycles
  • 15. What we say, what we mean
    • Unbounded Taskflow
      • Serve as the entry point to an application
      • First entry on task flow stack — the outer-most task flow
      • No well-defined boundary or single point of entry
      • Used to define the “top level” flow of an application
      • Used to build menu models
      • Declarative bookmarking of view activities
    • Bounded Taskflow
      • Reusable &quot;white box&quot; navigation and processing
      • Single point of entry
      • Well-defined boundary
      • Own memory scope
      • Declarative transaction management
      • Declarative Back button support
      • Input/output parameters
  • 16. Key Concepts
    • View Activity
    • Transitions (navigation rules)
    • Method Execution
    • Router
    • Exception handling
  • 17. Key Navigation Components
    • Method Call
      • Invokes application logic within application control flows, not within the page markup itself as in standard JSF applications.
      • The method call activity typically invokes a method on a managed bean
    • Router
      • Evaluates an EL expression and returns an outcome based on the value of the expression
    • Save Point and Restore
      • Restores a previous persistent Save Point in an application supporting save for later functionality
    • Task Flow Call
      • Calls an ADF bounded task flow from a particular point in an application
    • Task Flow Return
      • Identifies when a bounded task flow completes and sends control flow back to the caller
  • 18. Key Navigation Components
    • URL View
      • Redirects the root view port (for example, a browser page) to any URL addressable resource, even from within the context of an ADF region
    • View
      • Displays a JSF page or page fragment. Multiple View activities can represent the same page or same page fragment
    • Control Flow Case
      • Identifies how control passes from one activity to the next in the application
    • Wild Card Control Flow Rule
      • Represents a control flow rule that can originate from any activities whose ids match a wildcard expression.
      • Uses trailing wildcard such as foo*
    • Parent Action
      • Option to call a parent navigation flow from a region
  • 19. View Activity
    • Display a named page
      • Allows the same page to be used in more than one context
        • Unlike JSF
      • Page usages can be parameterized to help with reuse
        • For example:
          • Sending different parameters to queries used by the page
          • Different boilerplate text e.g. page title
    • Transitions or events link from pages to other activities
    • Redirect or forward
    <view id=&quot;reducedAccess&quot;> <page>/secured/information.jspx</page> <input-page-parameter> <from-value> #{res['infoUsage.messageHeader']} </from-value> <to-value> #{pageFlowScope.infoPageHeaderText} </to-value> </input-page-parameter> <input-page-parameter> <from-value>info</from-value> <to-value> #{pageFlowScope.infoPageType} </to-value> </input-page-parameter> </view>
  • 20. Transition aka Control Flow Case
    • The named “events” that link activities
      • Just like JSF navigation rules
      • Raised by command items in the page
        • buttons / links / menus
        • Defined as the action attribute, or the result of action code
    • Transitions have a source
      • Combination of page and raising method
      • Wildcards are allowed so “global” rules are possible
    • Transitions have a destination
      • An activity
    • What does it really mean?
      • You just draw a line on the diagram!
  • 21. Transitions <control-flow-rule> <from-activity-id> editRecord </from-activity-id> <control-flow-case> <from-outcome>pagehelp</from-outcome> <to-activity-id>appHelp</to-activity-id> </control-flow-case> </control-flow-rule> editRecord appHelp pageHelp globalHelp <control-flow-rule> <from-activity-id>*</from-activity-id> <control-flow-case> <from-outcome>globalhelp</from-outcome> <to-activity-id>appHelp</to-activity-id> </control-flow-case> </control-flow-rule>
  • 22. Methods
    • Execute code as part of a flow
      • For example before a page to set up data
      • Not available in JSF (although Struts has it)
    • Methods defined in Java and referenced through EL
    • Parameters – literals or from EL
    • Output from the method can be used to trigger navigation
      • If returns a String value (or something that can be converted to a string)
      • A fixed outcome is also possible
      • The method return value can be stored through EL
    • Method activities can be bound to backend business services
  • 23. Using URL View Activities
    • You can use a URL view activity to redirect the root view port (for example, a browser page) to any URL addressable resource, even from within the context of an ADF region.
    • URL addressable resources include:
      • ADF bounded task flow
      • view activities in an ADF unbounded task flow
      • addresses external to the current web application (for example, Google)
  • 24. Demonstration Unbounded Taskflow
  • 25. Bookmarking View Activities
      • Available only in unbounded task flows
        • Can designate in Property Inspector at design time
        • Can designate at run time with the ViewBookmarkable() method
        • Can optionally specify:
          • URL parameters
          • Method to invoke before view is rendered
      • You can use the redirect option for a view activity instead of making it bookmarkable
  • 26. <Insert Picture Here> Cool Stuff Sub-Flows
  • 27. Task Flow Templates
      • Capture common behavior for reuse across different ADF bounded task flows
        • For example, common exception handling
      • Can be created from an existing task flow
      • Template changes can be automatically propagated to any instance that uses it
        • Reuse by copy
        • Reuse by reference
  • 28. Now it Gets Interesting…
    • There are actually two types of task flow
      • Unbounded
      • Bounded
    • Unbounded task flows are just like JSF or Struts navigation rules
      • Any activity is accessible from the URL
      • No real beginning or end
      • Plus some cool stuff
        • Automatic menu generation based on the pages in the flow
  • 29. Bounded Task Flows
    • Can be nested within and called from other task flows
      • Invoked Task flow call activity
      • Treated like any other activity
      • Parent is suspended whilst the sub-flow has “focus”
    • Has a defined API
      • Parameters and outcomes (just like view activities)
    • Has a strict entry point – users can't just jump to a page
      • Special handling for the browser back button
    • Initializer and Finalizer code can be defined
      • Automatically run
    • Can be created based on templates
  • 30. Bounded Task Flow Example editRecord addCust createCustomer Bounded Task Flow
  • 31. Passing Parameters to an ADF Bounded Task Flow
    • To pass an input parameter to a bounded task flow, you must specify:
      • Input parameter on the task flow call activity. These specify where the calling task flow will store parameter values
      • Input parameter definition on the called bounded task flow. These specify where the called bounded task flow can retrieve parameter values.
      • The input parameter name specified for each of the above options will be the same in order to map input parameter values back into the called bounded task flow.
      • The value for each corresponds to the mapping between where the value will be retrieved within the caller and the called task flow.
  • 32. Back Button Support: Reentering an ADF Bounded Task Flow
    • You can specify what to do when the user clicks the back button to navigate back into a bound task
      • reentry-allowed
        • end user can re-enter the task flow
      • reentry-not-allowed
        • use can navigate back into the task flow, but doing anything on the page throws an exception
      • reentry-outcome-dependent
        • Reentry of the calling bounded task flow is dependent on the outcome received when exiting the called bounded task flow.
  • 33. Demonstration Bounded Taskflow
  • 34. <Insert Picture Here> &quot;To go or not to Go&quot; Router Decisions
  • 35. Routers
    • Controlling flow in a declarative manner
    • Basically a SWITCH construct for flow
    • Series of outcomes linked to EL
      • If the expression evaluates to true then the outcome is set
    <router id=&quot;userTypeCheck&quot;> <case> <expression> #{userType == ‘MANAGER_ROLE'} </expression> <outcome>manager</outcome> </case> <case>…</case> <default-outcome> forbidden </default-outcome> </router>
  • 36. Demonstration Routers
  • 37. <Insert Picture Here> Exceptions, Transactions and Scopes
  • 38. Exception Handling
    • Exceptions can be mapped to an activity
    • Generally for unexpected exceptions or security violations
      • Not a “normal” part of a flow
    • Only one handler per flow
      • However, that could be a method or a router if different errors need different handling
  • 39. Transactional Semantics
    • Bounded task flows can also define transaction boundaries
      • When a flow is started, you can define:
        • A new transactional state should be created
        • The existing state should be reused
      • Declaratively do an automatic commit or rollback when the flow ends
        • Depending on end state if required
  • 40. It’s a Matter of Scope
    • This is the most important thing…
    • Task flows have a private memory scope - PageFlowScope
      • Plus the usual request, session and application scopes
    • Accessed via expression language like the other scopes - #{pageflowScope.bean}
    • Private to each flow (and instance of a flow)
      • This allows nesting and reuse
    • Data mapped in and out in call activities and task flow returns
  • 41. Available Object Scopes
  • 42. Trains
    • Bounded task flows can define a train
    • The framework Maintains knowledge of there you are
    • Train control and Navigation buttons automatically managed
  • 43. <Insert Picture Here> Regions The Magic of Ajax
  • 44. It’s Not Just Pages
    • Bounded task flows can be made up of page fragments (.jsff files)
    • Such flows can then be embedded into pages as “regions”
    • This is a very common pattern allowing the creation of complex pages made up of a series of re-usable components (ie. Task Flows)
    • Just drag and drop the flow into the page
  • 45. Demonstration Regions
  • 46. What You Should Know
    • The ADF controller only operates in a JSF 2.0 environment
    • Oracle's web-based ADF application strategy focuses on JSF as the sole view layer technology
    • ADF controller extensions are implemented on top of Oracle's ADF Faces.
    • ADF controller extensions do not run against the reference or MyFaces implementations of JSF unless ADF Faces is present
    • There is no support for a migration from Struts or Model 1 to the Fusion ADF Controller
    • The developer will use ADF Bounded Task Flows to manage transaction boundaries.
    • Page Flow scope is not available before the restore view phase
  • 47. Summary
    • ADF Task Flow is one of the major new features of JDeveloper & ADF R11
    • Meets the needs of changing UIs
      • Modern AJAX applications have fewer richer pages
      • Fragment based task flows address this
  • 48. Join the JDeveloper/ADF Community Twitter Facebook Oracle’s JDeveloper PM blog / JDeveloperpm
  • 49. Q U E S T I O N S A N S W E R S &
  • 50.