Oracle ADF Interview Question and Answers
Oracle ADF Interview Question and Answers
Initialize Context: In this phase the adf page initializes the LifecycleContext
with information that will be used during the Lifecycle.
Prepare Model: In this phase ui model is prepared and initialized. In this
phase page parameters are set and methods in the executable section of the
page definition of the ADF page are executed.
Apply Input Values: This phase handles the request parameters. The values
from the HTML are sent to the server and applied to the page binding in page
definitions.
Validate Input Values: This phase validates the values that were built in
the Apply input values phase
Update Model: Validated values supplied from user are sent to ADF business
components data model
Validate Model Updates: In this phase the business components will
validate user supplied values.
Invoke Application: This phase will process the ui events stack built during
the life cycle of page and also fire navigational events
Prepare Render: This is the final phase where HTML code is generated from
the view tree.
5 View Criteria
View criteria are structured criteria that you can use to create searches.
View criteria are collections of view criteria rows. A view criteria row specifies
query-by-example requirements for one or more view object attributes. A view
row matches if it meets all of the requirements.
When you apply view criteria to a view object instance, the query is restricted to
return those view rows that match at least one of the view criteria rows.
Effectively, therefore, view criteria assemble a WHERE clause in conjunctive
normal form: the WHERE clause is a disjunction of conjunctions of query-by-
example requirements.
View criteria are implemented by the class oracle.jbo.ViewCriteria; view
criteria rows, by the classoracle.jbo.ViewCriteriaRow.
ADF View Link: Oracle ADF view links are business components that
define a relationship between two Oracle ADF view object definitions (the
"source" and "destination" view objects) based on sets of view attributes
(the "source" and "destination" attributes) from each. These can range
from simple one-to-many relationships to complex many-to-many
relationships. This allows you to easily create master/detail relationships
between data controls in the client. For example, creating a view link
between view objects will allow you to create relationships between:
A dropdown list for selecting a customer and a table displaying that customer's
orders
The nodes in a tree control and their respective children
An HTML page containing two frames: one that allows the user to browse for
items and the other that lists the warehouse in which the selected item is stored
Because view objects are data model components, you should consider your
client's data needs when defining them. Decide which controls will need to be
related, and which view objects will manage them.
View link definitions, which consist of an XML file that defines the view link
View link instances, which are particular references to a Oracle ADF view link
definition within a Oracle ADF application module definition.
View Accessors:
Use to define the list of available view accessors on the current entity object or
view object.
View accessors are value-accessor objects in ADF Business Components. You
create a view accessor to point from a base entity object attribute or view object
attribute to a source view row set.
The view accessor returns a list of all possible values to the attribute of the base
object.
1 Accessor Attributes
When you create a view link definition between two view object definitions, you
can select to add accessor attributes to the source view object definition, the
destination view object definition, or both. These accessor attributes function
much like the accessor attributes to associations:
Their names can be passed as arguments to ViewObjectImpl.getAttribute().
If you generate a view row class, a getter method for the accessor attributes will
be included in the class.
The accessor method will return a view row or a row iterator, depending on the
cardinality of the view link definition.
An accessor attribute returns a row or row iterator that is static, not one that
maintains a synchronized master-detail relationship. For example, suppose
DepartmentEmployees is an accessor attribute that returns rows of
EmployeesView from rows of DepartmentView. Suppose you execute the
following code on the current row of DepartmentView:
Then suppose the current row of DepartmentView changes. The row iterator
in details will not change: it will still contain details of the original row.
2 Cardinality:
Like associations, view link definitions can be one-to-one, one-to-many, or many-
to-many. One-to-one and one-to-many view link definitions can either be based
on associations or they can use attribute matching the way associations do.
Many-to-many view link definitions must be based on many-to-many
associations.
Scope Description
application The application scope lasts until the application stops.
Values that you store in a managed bean with this scope are
available to every session and every request that uses the
application.
Avoid using this scope in a task flow because it persists
beyond the life span of the task flow.
session The session scope begins when a user first accesses a page
Scope Description
in the application and ends when the user's session times
out due to inactivity, or when the application invalidates the
session.
Use this scope only for information that is relevant to the
whole session, such as user or context information. Avoid
using it to pass values from one task flow to another.
Instead, use parameters to pass values between task flows.
Using parameters gives your task flow a clear contract with
other task flows that call it or are called by it. Another reason
to avoid use of session scope is because it may persist
beyond the life span of the task flow.
pageFlow Choose this scope if you want the managed bean to be
accessible across the activities within a task flow. A
managed bean that has a pageFlow scope shares state with
pages from the task flow that access it. A managed bean
that has a pageFlow scope exists for the life span of the task
flow.If another task flow's page references the managed
bean, the managed bean creates a separate instance of this
object and adds it to the pageFlow scope of its task flow.
view Use this scope for managed bean objects that are needed
only within the current view activity and not across view
activities. It defines scope for each view port that ADF
Controller manages, for example, a root browser window or
an ADF region.
The life span of this scope begins and ends when the
current viewId of a view port changes. If you specify view,
the application retains managed bean objects used on a
page as long as the user continues to interact with the page.
These objects are automatically released when the user
leaves the page.
request Use request scope when the managed bean does not need
to persist longer than the current request.
backingBean A backing bean is a convention to describe a managed bean
that stores accessors for UI components and event handling
code on a JSF page. It exists for the duration of a request and
should not be used to maintain state.
Use this scope if it is possible that your task flow appears in
two ADF regions on the same JSF page and you want to
isolate each instance of ADF region.
Keep immediate=true
A very common way to skip validation is by keeping the value for immediate
attribute as 'true' for the UIComponents. Immediate attribute allow processing of
components to move up to the Apply Request Values phase of the lifecycle.
scenario:
While canceling a specific action, system should not perform the validation. One
possible way to achieve this is by keeping immediate=true associated with UI
element. To know more abut this feature, please refer this wiki.
Sometimes you may need to update UI controls with model data as part of the
‘immediate’ action. Make sure that you call resetValue() on the UIInput in this
scenario. This causes to reset the submitted value and would ensure that UI gets
updated with right value from the model.
SkipValidation
2. This property doesn’t have any effect on the client side validation (even if it is
generated using the EL bound with model layer)
SkipValidation can be located as part of the root node of the page definition file.
Possible values for SkipValidation are given below.
a. SkipValidation=true
Setting ‘SkipValidation’ property to true will bypass the ADF Model validation. In
this case validation happens only when you commit the transaction( i.e: when
you call transaction.commit()). Please note that SkipValidation skips only the
entity level validation. The attribute level validation fire irrespective of the value
for the boolean flag
Scenario:
This is useful where you need to delay the validation till the point where
transaction gets committed to Database. There are cases where business data
needs to be captured in bulk. A typical example would be capturing transaction
data using a grid form/tabular list. Business user must be able to key in values in
any order. i.e. even without completing the data capture for the current record,
user must be able to move to next set of records. Here model level validation
needs to be delayed till we really save the data. SkipValidation=true is the right
option to achieve this sort of use case, which does the validation across records,
only while committing the transaction.
b. SkipValidation=custom
This gives more control to the developer while validating the data. Only
validates(or rather executes) what is given in custom implementation for
BindingContainerValidator. It is much useful in complex business scenarios
where developer needs finer control on validation.
c. SkipValidation=skipDataControls
skipDataControls means that it will skip the data control level validation (also
known as Transaction Level validation) and instead only will validate data in the
row or rows which got updated through iterator in the current binding container.
Scenario:
The property is very much useful while dealing with below given scenarios.
2. Same page is making use of multiple Data Controls. Here commit on one Data
Control should not trigger validation on other Data Controls defined in the same
page.
d. SkipValidation=false
This is the default value for SkipValidation, apparently this setting just ensures
the normal flow for validation during form submission.
Q.What is view link? How to create it? What is idea behind it?
A: View Link is an active link between view objects.You can create view
links by providing the Source & destination VO attributes.
Oracle ADF view links are business components that define a relationship
between two Oracle ADF view object definitions (the "source" and "destination"
view objects) based on sets of view attributes (the "source" and "destination"
attributes) from each.
These can range from simple one-to-many relationships to complexmany-to-
many relationships. This allows you to easily create master/detail relationships
between data controls in the client. For example, creating a view link between
view objects will allow you to create relationships between:
A dropdown list for selecting a customer and a table displaying that customer's
orders
The nodes in a tree control and their respective children
An HTML page containing two frames: one that allows the user to browse for
items and the other that lists the wherehouses in which the selected item is
stored
View Links can be created using:
1. Two View objects
2. Based on EO Association
For example, suppose you had the following view object definitions:
You could then use CustOrdLink conjunction with a row fromCustomersView (for
example, the row for Customer 101) and all of OrdersView to return the rows from
the query
SELECT * FROM ORDERS WHERE 101 = ORDERS.CUSTOMER_ID
JDeveloper will create the parametrized query for you based on the attributes
you select. If you do not change this query, you can make the view link
bidirectional. This will switch the roles of the source and destination attributes.
For example, if you make CustOrdLink bidirectional, you can use it in conjunction
with a row from OrdersView (for example, a row for an order placed by Customer
101) and all of CustomersView to return the rows from the query
SELECT * FROM CUSTOMERS WHERE CUSTOMERS.CUSTOMER_ID = 101
JDeveloper manages storing the hints in a way that is easy to localize for multi-
lingual applications.
Method Bindings: This binding is used when you want to use custom methods
to be executed.
Tree Bindings: This is used for tables, tree-tables and trees. It is used to
expose rows of a table in the iterator binding’s current range. Eg; All
Customers-#{bindings.AllCustomers.labels.CustomerId}
Iterator Binding: This binding is created by the application to access the ADF
binding context. It contains a reference to the page bound data collection, helps
access it and iterates over its data objects.
A: code to access the current row and or the view object inside your bean:
BindingContainer bc =
BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding lBinding =
dcbc.findIteratorBinding("EmployeesViewIterator");
You can also use the Create View Object wizard to create the attributes based on
data from a comma-separated value (CSV) file format like a spreadsheet file. The
wizard will attempt to create the attributes that you define in the wizard with
data from the first row of the flat file.
Check below image- circled import option is to import comma separated .cvs file
or other file.
Q: Can we change DB connection for any particular AM?
A: YES, follow steps to change DB connection:
1. Double click on AM.
2. GO to the configuration tab, click on configuration file bc4j.xml
3. Here we have attribute JDBCName under element AppModuleConfig, change
the connection which is created for other DB.
Q: What is view criteria, how can you change view criteria at runtime?
A: View Criteria: View criteria are structured criteria that you can use to create
searches.
View criteria are collections of view criteria rows. A view criteria row specifies
query-by-example requirements for one or more view object attributes. A view
row matches if it meets all of the requirements.
When you apply view criteria to a view object instance, the query is restricted to
return those view rows that match at least one of the view criteria rows.
Effectively, therefore, view criteria assemble a WHERE clause in conjunctive
normal form: the WHERE clause is a disjunction of conjunctions of query-by-
example requirements.
View criteria are implemented by the class - oracle.jbo.ViewCriteria;
view criteria rows, by the classoracle.jbo.ViewCriteriaRow.
Sometimes you need dynamic ViewCriteria that you can handle at runtime ,
here is the solution ,you can create and apply ViewCriteria Programmatically-
Sample UseCase-
/**Get ViewObject*/
ViewObject vo = getAm().getDepartments1();
/**Create ViewCriteria on ViewObject*/
ViewCriteria vc = vo.createViewCriteria();
/**Create ViewCriteriaRow for that Criteria*/
ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
/**Set the values for ViewCriteriaRow*/
vcRow.setAttribute("DepartmentId", 10);
/**Add row to ViewCriteria*/
vc.addRow(vcRow);
/**Apply Criteria on ViewObject*/
vo.applyViewCriteria(vc);
/**Execute ViewObject*/
vo.executeQuery();
You typically will not need to change this default setting. However it is important
to understand that it is enabled by default since it effects how validation
exceptions are thrown. Since the Java language and runtime only support
throwing a single exception object, the way that bundled validation exceptions
are implemented is by wrapping a set of exceptions as details of a new "parent"
exception that contains them. For example, if multiple attributes in a single
entity object fail attribute-level validation, then these
multipleValidationException objects will be wrapped in a RowValException.
This wrapping exception contains the row key of the row that has failed
validation. At transaction commit time, if multiple rows do not successfully pass
the validation performed during commit, then all of
the RowValException objects will get wrapped in an enclosing TxnValException
object.
When writing custom error processing code, you can use the getDetails() method
of the JboException base exception class to recursively process the bundled
exceptions contained inside it.
Note: All the exception classes mentioned here are in the oracle.jbo package.