Accessing the View Object for Programmatic Access to Business Objects
A "view object" is an Oracle ADF component that simplifies querying and working with business object rows. The newView() function allows you to access a view object dedicated to programmatic access for a given business object.
By default, any custom object you create is enabled to have such a view object, and
selected standard objects will be so-enabled by the developers of the original
application you are customizing. Each time the newView(objectAPIName)
function is invoked for a given value of object API name, a new view object instance is
created for its programmatic access. This new view object instance is in a predictable
initial state. Typically, the first thing you will then do with this new view object
instance is:
-
Call the
findByKey()
function on the view object to find a row by key, or -
Append a view criteria to restrict the view object to only return some desired subset of business objects rows that meet your needs, as described in Finding Objects Using a View Criteria.
A view object will typically be configured to return its results in sorted order. If the
default sort order does not meet your needs, you can use the
setSortBy()
method on the view object to provide a comma-separated
list of field names on which to sort the results. The new sort order will take effect
the next time you call the executeQuery()
method on the view object.
See Defining the Sort Order for Query Results for further details on sorting options available.
A view object instance for programmatic access to a business object is guaranteed not to be used by any application user interface pages. This means that any iteration you perform on the view object in your script will not inadvertently affect the current row seen in the user interface. That said, the end user will see the results of any field values that you change, any new rows that you add, and any existing rows that you modify, presuming that they are presently on a page where said objects and fields are visible.
For example, suppose the user interface is displaying an employee along with the number and associated name of the department in which she works. If a script that you write...
-
uses
newView()
to obtain the view object for programmatic access for theDepartment
object, then -
uses
findByKey()
to find the department whose id matches the current employee's department, and finally -
changes the name of the current employee's department
then this change should be reflected in the screen the next time it is updated. Once you've accessed the view object, the most common methods that you will use on the view object are shown in the following table.
Method Name |
Description |
---|---|
|
Allows you to find a row by unique id. Returns: an array of rows having the given key, typically containing either zero or one row. Parameters:
Example: See Finding an Object by Id |
|
Allows you to find a set of matching rows based on a filter criteria.
Returns: an iterator you can use to process the matching rows
using methods Parameters:
Example: See Finding Rows in a Child Rowset Using findRowsMatchingCriteria |
|
Appends an additional view criteria query filter. Parameters:
Returns: - Alternatively, if you already have created a view criteria using
|
|
Executes the view object's query with any currently appended view criteria filters.
Returns: - |
|
Returns: - |
|
Returns: - the next row in the iterator |
|
Resets the view object's iterator to the "slot" before the first row.
Returns: - |
|
Returns: - the first row in the row iterator, or
|
|
Creates a new row, automatically populating its system-generated
Returns: - the new row |
|
Inserts a new row into the view object's set of rows.
Returns: - |
|
Set the sort order for query results.
Returns: - |