+ All Categories
Home > Documents > 13_Creating Update Able Pages

13_Creating Update Able Pages

Date post: 30-May-2018
Category:
Upload: suresh1130
View: 213 times
Download: 0 times
Share this document with a friend

of 24

Transcript
  • 8/14/2019 13_Creating Update Able Pages

    1/24

    13Copyright 2007, Oracle. All rights reserved.

    Creating Updatable Pages

  • 8/14/2019 13_Creating Update Able Pages

    2/24

    13-2 Copyright 2007, Oracle. All rights reserved.

    Objectives

    After completing this lesson, you should be able to do

    the following:

    Use components that facilitate data entry

    Invoke method actions in the page definition Bind methods to buttons

    Use transactional methods:

    mergeEntity

    refreshEntity removeEntity

    persistEntity

    Call methods from a Managed Bean

  • 8/14/2019 13_Creating Update Able Pages

    3/24

    13-3 Copyright 2007, Oracle. All rights reserved.

    Using Components That

    Facilitate Data Entry

    SelectInputDate component

    SelectOneChoice

    component

  • 8/14/2019 13_Creating Update Able Pages

    4/24

    13-4 Copyright 2007, Oracle. All rights reserved.

    Using Methods on Pages

    You can use methods to (for example):

    Decide navigational outcomes

    Pass parameters

    Execute business logic Perform Create-Retrieve-Update-Delete (CRUD)

    transactions

  • 8/14/2019 13_Creating Update Able Pages

    5/24

    13-5 Copyright 2007, Oracle. All rights reserved.

    Executing Methods in ADF

    Methods are defined in the page

    definition file as operation

    bindings.

    Operations can be accessed andexecuted from ADF Faces.

    Enterprise JavaBeans (EJBs) use

    methods on the ADF binding for

    CRUD operations.

  • 8/14/2019 13_Creating Update Able Pages

    6/24

    13-6 Copyright 2007, Oracle. All rights reserved.

    Executing 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.

    Use ExpressionLanguage to set

    conditions that

    determine when an

    action is executed.

  • 8/14/2019 13_Creating Update Able Pages

    7/2413-7 Copyright 2007, Oracle. All rights reserved.

    Constructors

    Constructors:

    Are methods created as

    part of the Data Control

    Are added to theConstructors node

    Create a new object

    Can be used to build ADF

    creation forms

  • 8/14/2019 13_Creating Update Able Pages

    8/2413-8 Copyright 2007, Oracle. All rights reserved.

    Transactional Methods

    The Session Facade includes the following methods

    for transactions:

    mergeEntity

    persistEntity refreshEntity

    removeEntity

  • 8/14/2019 13_Creating Update Able Pages

    9/2413-9 Copyright 2007, Oracle. All rights reserved.

    mergeEntity()

    mergeEntity():

    Is added to the Session Facade Bean

    Is used for committing updates

    Checks for existence Merges transaction into unit of work

    Commits the transaction

  • 8/14/2019 13_Creating Update Able Pages

    10/2413-10 Copyright 2007, Oracle. All rights reserved.

    persistEntity()

    persistEntity():

    Is part of the Session Facade Bean

    Is used for inserts

    Checks for duplicates in unit of work Inserts an entity

    Commits the transaction

  • 8/14/2019 13_Creating Update Able Pages

    11/2413-11 Copyright 2007, Oracle. All rights reserved.

    Using Transactional Methods

    1

    2

    3

    1

  • 8/14/2019 13_Creating Update Able Pages

    12/2413-12 Copyright 2007, Oracle. All rights reserved.

    Building an Insert Form

    You use a default

    constructor.

    JDeveloper builds an

    ADF Creation Form. The constructor is called

    when the page is loaded.

    The properties are

    populated on submit.

  • 8/14/2019 13_Creating Update Able Pages

    13/2413-13 Copyright 2007, Oracle. All rights reserved.

    Building an Insert Form

    Add the

    persistEntity()

    method.

    Add it as a button orbind it to an existing

    button.

    Pass the newly created

    entity to the method.

  • 8/14/2019 13_Creating Update Able Pages

    14/2413-14 Copyright 2007, Oracle. All rights reserved.

    Building an Insert Form

    Change the Action property to point to a

    navigation case.

    Add a Cancel button.

  • 8/14/2019 13_Creating Update Able Pages

    15/2413-15 Copyright 2007, Oracle. All rights reserved.

    Displaying the Results

    Navigate to the

    calling page.

    Set Cache Results

    to false on theiterator.

    The queries are

    reexecuted each

    time the page is

    reloaded.

  • 8/14/2019 13_Creating Update Able Pages

    16/2413-16 Copyright 2007, Oracle. All rights reserved.

    Using Backing Beans

    Managed Beans can contain:

    Business logic

    Interaction with data sources

    Backing beans are a special type of Managed Beanthat:

    Interact with the User Interface (UI) components

    and the model

    Are associated with UI components by using JSF

    Expression Language Can contain event listener methods

    Contain getter and setter methods for UI

    components

  • 8/14/2019 13_Creating Update Able Pages

    17/2413-17 Copyright 2007, Oracle. All rights reserved.

    Backing Bean: Example

    JDeveloper creates for each field:

    Properties

    get() and set() methods

  • 8/14/2019 13_Creating Update Able Pages

    18/2413-18 Copyright 2007, Oracle. All rights reserved.

    Creating Backing Beans

    When you create a JSF

    page, you can choose

    to associate UI

    components with a

    Managed Bean.

    You manually create

    Managed Beans byassociating class files

    in the JSF

    Configuration Editor.

  • 8/14/2019 13_Creating Update Able Pages

    19/2413-19 Copyright 2007, Oracle. All rights reserved.

    Creating Backing Beans

    You can automatically create a Managed Bean when

    you create a page:

    Attribute and

    getter or setter

    methods for each

    UI component

    Managed Bean

    automatically

    synchronized withUI changes

  • 8/14/2019 13_Creating Update Able Pages

    20/2413-20 Copyright 2007, Oracle. All rights reserved.

    Creating Managed Beans by Binding a

    Command Button

    You can also create a Managed Bean from the page:

    1. Double-click the Command button.

    2. Click New.

    3. Name the bean and class.4. Select the scope.

    5. If the class does not exist, JDeveloper creates it.

  • 8/14/2019 13_Creating Update Able Pages

    21/2413-21 Copyright 2007, Oracle. All rights reserved.

    ADF Binding

  • 8/14/2019 13_Creating Update Able Pages

    22/2413-22 Copyright 2007, Oracle. All rights reserved.

    Configuring ADF Binding Access for

    Managed Beans

    Create a managed propertyand set its value to

    #{bindings}.

    In the Managed Bean, create an

    instance variable with thesame name as the

    managed property.

    Make sure the variable type

    is oracle.binding.BindingContainer.

    Create setter and getter methods for the instancevariable.

    The binding is automatically configured on

    declarative method binding creation.

  • 8/14/2019 13_Creating Update Able Pages

    23/2413-23 Copyright 2007, Oracle. All rights reserved.

    Summary

    In this lesson, you should have learned how to:

    Use components that facilitate data entry

    Invoke method actions in the page definition

    Bind methods to buttons Create an Insert page

    Use transactional methods:

    mergeEntity

    refreshEntity removeEntity

    persistEntity

    Create and use Managed Beans

  • 8/14/2019 13_Creating Update Able Pages

    24/24

    Practice Overview:

    Completing the Edit Page

    This practice covers the following topics:

    Creating a Query page

    Using a constructor for an Insert page

    UsingpersistEntity() to commit changes to thedatabase

    Adding components to the SREdit page to make it

    more user-friendly

    Committing an update


Recommended