Sie sind auf Seite 1von 41

Declaratively Customizing Data Services

Copyright 2008, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to do the


following:
Describe how to declaratively change data behavior
Declaratively modify view objects, entity objects, and
application modules
Create view accessors
Create LOVs

7-2 Copyright 2008, Oracle. All rights reserved.


Using Groovy

Groovy
Is a Java-like scripting language that is dynamically
compiled and evaluated at run time
Enables you to use declarative expressions, instead of
writing Java code, for the following types of values in the
ADF BC data model:
Bind variables
Calculated attributes
Attribute default values
View criteria
View accessor bind variables
Validation
Validation message token binding
7-3 Copyright 2008, Oracle. All rights reserved.
Using Groovy Syntax in ADF

Java Code Equivalent


Groovy script
((Number)getAttribute("Sal").multiply(new Sal * 0.10
Number(0.10))
((Date)getAttribute("PromotionDate")).compareTo PromotionDate
((Date)getAttribute("HireDate")) > 0 > HireDate

Reserved name adf gets objects from framework:


adf.context
adf.object
adf.error
adf.currentDate
adf.currentDateTime

7-4 Copyright 2008, Oracle. All rights reserved.


Internationalizing the Data Model

When an application is internationalized, the UI displays


text based on users
browser settings.
To use resource
bundles for translatable
strings you can:
Create one bundle
per file or project
Translate and
append
_<locale>
to file name
Configure the UI

7-6 Copyright 2008, Oracle. All rights reserved.


Editing Business Components

Editors provide access to business component properties:

Property Inspector
Entity Object Editor

7-7 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of Entity Objects

With declarative settings, you can:


Define attribute control hints
Synchronize columns with
trigger-assigned values
Use alternate key entity
constraints
Validate user input (presented in the lesson titled
Validating User Input)

7-8 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of Entity Objects

With declarative settings, you can:


Define attribute control hints
Synchronize columns with
trigger-assigned values
Use alternate key entity
constraints
Validate user input (presented in the lesson titled
Validating User Input)

7-9 Copyright 2008, Oracle. All rights reserved.


Defining Attribute Control Hints

2 3

7 - 10 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of Entity Objects

With declarative settings, you can:


Define attribute control hints
Synchronize columns with
trigger-assigned values XXXXXXXXX
Use alternate key entity
constraints
Validate user input (presented in the lesson titled
Validating User Input)

7 - 12 Copyright 2008, Oracle. All rights reserved.


Synchronizing with Trigger-Assigned Values

To synchronize when database trigger updates a column,


use Refresh After Update or Refresh After Insert.
To use a database sequence to generate a primary key:
Set data type of
attribute to
DBSequence
Set Updatable to
Never
Refresh After
Insert is selected
automatically

7 - 13 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of Entity Objects

With declarative settings, you can:


Define attribute control hints
Synchronize columns with
trigger-assigned values
Use alternate key entity
constraints
Validate user input (presented in the lesson titled
Validating User Input)

7 - 15 Copyright 2008, Oracle. All rights reserved.


Using Alternate Key
Entity Constraints

Alternate keys are:


Used for efficient uniqueness checks
Used for direct row lookups with findByKey() methods
Different from primary keys or unique keys

7 - 16 Copyright 2008, Oracle. All rights reserved.


Creating Alternate Key
Entity Constraints

Use the New Entity Constraint Wizard:


1 2

7 - 17 Copyright 2008, Oracle. All rights reserved.


Creating Alternate Key
Entity Constraints

3 4

7 - 18 Copyright 2008, Oracle. All rights reserved.


Editing View Objects

7 - 19 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 20 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 21 Copyright 2008, Oracle. All rights reserved.


Defining View Object Control Hints

Same as for entity objects


Overrides EO control hint settings: Use in cases such as:
The same data must be displayed differently in different
views.
OR
The VO uses the same attribute twice as in a recursive
relationship.
Can also be used for transient attributes defined at VO
level

7 - 22 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 24 Copyright 2008, Oracle. All rights reserved.


Performing Calculations

Setting recalculation
dependencies

7 - 25 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 26 Copyright 2008, Oracle. All rights reserved.


Restricting and Reordering
the Columns Retrieved by a Query

Use the Attributes tab of editor to delete or reorder


attributes.
Query changes to reflect the new SELECT clause.

Original query Deleting attributes

Modified
query
Reordering attributes

7 - 27 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 28 Copyright 2008, Oracle. All rights reserved.


Changing the Order of Queried Rows

To change the order, perform the following steps:


1. Click the Query tab of the view object editor.
2. Click Edit in the Query section of the panel.
3. Click Edit in the Edit Query dialog box.
4. In the Order By dialog box, select the columns for sorting
the rows retrieved by the query.

7 - 29 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 30 Copyright 2008, Oracle. All rights reserved.


Restricting the Rows Retrieved by a Query

Add a WHERE
clause:

7 - 31 Copyright 2008, Oracle. All rights reserved.


Using View Criteria
(Structured WHERE Clauses)

You can use the view criteria to define complex query


criteria at design time.
You can specify execution mode.

7 - 32 Copyright 2008, Oracle. All rights reserved.


Using Parameterized WHERE Clauses

Edit the
1
view object.
Add a
Edit the SQL 3 parameterized
2 WHERE clause.
query.

7 - 34 Copyright 2008, Oracle. All rights reserved.


Using Named Bind Variables

1 3

2 4

7 - 35 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 36 Copyright 2008, Oracle. All rights reserved.


Retaining and Reusing a
View Link Accessor Row Set

Retaining a view link accessor row set:


Enables caching of the view link
accessor RowSet object
Avoids overhead of creating new
detail RowSet objects
May be advisable when application
makes numerous calls to the same
view link accessor attributes
Can be implemented declaratively
in the Tuning section of the
General tab for view object that is
the source for the view link

7 - 37 Copyright 2008, Oracle. All rights reserved.


Modifying the Default Behavior of View Objects

With declarative settings, you can:


Define attribute control hints
Perform calculations
Restrict the columns retrieved by a query
Change the order of queried rows
Restrict the rows retrieved by a query
Retain and reuse a row set
Define a list of values

7 - 38 Copyright 2008, Oracle. All rights reserved.


Creating View Accessors

View accessors are used for validation and LOVs.


Create on View Accessors page of EO or VO editor

7 - 39 Copyright 2008, Oracle. All rights reserved.


Using a List of Values (LOV)

LOVs:
Are defined on view object attributes
Use view accessors as a data source:
For attributes mapped to an entity object attribute:
Use the view accessor that is used by the entity object
attributes Key Exists validator.
Extend the view accessor at the view object level for UI hints or
bind expressions if required.
For transient attributes, you can define a new view accessor.

7 - 40 Copyright 2008, Oracle. All rights reserved.


Defining the View Accessor for the List of Values

7 - 41 Copyright 2008, Oracle. All rights reserved.


Defining the List of Values

1 3

2 4

7 - 42 Copyright 2008, Oracle. All rights reserved.


Modifying Application Modules

The Application Module editor has the following tabs:


General: Set tuning parameters, define custom properties.
Data Model: Refine the data model.
Java: Create Java classes, expose methods to the client
interface.
EJB Session Bean: Enable EJB session bean support.
Configurations: Create or modify sets of configuration
parameters.

7 - 43 Copyright 2008, Oracle. All rights reserved.


Changing the Locking Behavior
of an Application Module

Default locking behavior is pessimistic.


Optimistic locking is recommended for Web applications.
Change configuration: Set jbo.locking.mode to
optimistic or optupdate.

7 - 44 Copyright 2008, Oracle. All rights reserved.


Summary

In this lesson, you should have learned to:


Describe how to declaratively change data behavior
Declaratively modify view objects, entity objects, and
application modules
Create view accessors
Create LOVs

7 - 45 Copyright 2008, Oracle. All rights reserved.


Practice 7 Overview:
Declaratively Modifying Business Components

This practice covers the following topics:


Changing data labels and formats
Specifying that an entity object should use a database
sequence to generate the primary key
Designating history columns
Creating bind variables and view criteria
Creating join view objects
Defining an LOV

7 - 46 Copyright 2008, Oracle. All rights reserved.

Das könnte Ihnen auch gefallen