Documente Academic
Documente Profesional
Documente Cultură
search
APR
18
Oracle ADF Interview Question and Answers.
Q: Lifecycle of a Web Page Request Using Oracle ADF and JSF
Ans : Below figure shows a sequence diagram of the lifecycle of a web page
request using JSF and Oracle ADF in tandem.
Lifecycle of a Web Page Request Using JSF and Oracle ADF
Life Cycle of ADF
As shown in the figure, the basic flow of processing happens as follows:
A web request for http://yourserver/yourapp/faces/some.jsp arrives from the
client to the application server
The ADFBindingFilter finds the ADF binding context in the HTTP session, and if not
yet present, initializes it for the first time.
During binding context initialization, the ADFBindingFilter:
Consults the servlet context initialization parameter named CpxFileName and
appends the *.cpxfile extension to its value to determine the name of the binding
context metadata file. By default the parameter value will be DataBindings, so
it will look for a file named DataBindings.cpx.
Reads the binding context metadata file to discover the data control definitions,
the page definition file names used to instantiate binding containers at runtime,
and the page map that relates a JSP page to its page definition file.
Constructs an instance of each Data Control, and a reference to each
BindingContainer. The contents of each binding container are loaded lazily the
first time they are used by a page.
The ADFBindingFilter invokes the beginRequest() method on each data control
participating in the request. This gives every data control a notification at the
start of every request where they can perform any necessary setup.
An application module data control uses the beginRequest notification to acquire
an instance of the application module from the application module pool.
The JSF Lifecycle class, which is responsible for orchestrating the standard
processing phases of each request, notifies the ADFPhaseListener class during
each phase of the lifecycle so that it can perform custom processing to
coordinate the JSF lifecycle with the Oracle ADF Model data binding layer.
Note:
The FacesServlet (in javax.faces.webapp) is configured in the web.xmlfile of a JSF
application and is responsible for initially creating the JSFLifecycle class (in
javax.faces.lifecycle) to handle each request. However, since it is the Lifecycle
class that does all the interesting work, the FacesServlet is not shown in the
diagram.
The ADFPhaseListener creates an ADF PageLifecycle object to handle each
request and delegates appropriate before/after phase methods to corresponding
methods in the ADFPageLifecycle class as shown in If the appropriate binding
container for the page has never been used before during the users session, it is
created.
How JSF Page Lifecycle and ADF Page Lifecycle Phases Relate
The JSF Lifecycle forwards control to the page to be rendered.
The UI components on the page access value bindings and iterator bindings in
the pages binding container and render the formatted output to appear in the
browser.
The ADFBindingFilter invokes the end Request() method on each data control
participating in the request. This gives every data control a notification at the end
of every request where they can perform any necessary resource cleanup.
An application module data control uses the endRequest notification to release
the instance of the application module back to the application module pool.
The user sees the resulting page in the browser.
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.
Q : What is Action Listener ?
Ans : An action listener is a class that wants to be notified when a command
component fires an action event. An action listener contains an action
listener method that processes the action event object passed to it by
the command component
Q:What are ADF BC(Business Components) ?Describe them.
Ans: All of these features can be summarized by saying that using ADF
Business Components for your J2EE business service layer makes your life a
lot easier. The key ADF Business Components components that cooperate
to provide the business service implementation are:
Entity Object: An entity object represents a row in a database table and
simplifies modifying its data by handling all DML operations for you. It can
encapsulate business logic for the row to ensure your business rules are
consistently enforced. You associate an entity object with others to reflect
relationships in the underlying database schema to create a layer of business
domain objects to reuse in multiple applications.
Application Module: An application module is the transactional component that
UI clients use to work with application data. It defines an updatable data model
and top-level procedures and functions (called service methods) related to a
logical unit of work related to an end-user task.
View Object: A view object represents a SQL query and simplifies working with
its results. You use the full power of the familiar SQL language to join, project,
filter, sort, and aggregate data into exactly the shape required by the end-user
task at hand. This includes the ability to link a view object with others to create
master/detail hierarchies of any complexity. When end users modify data in the
user interface, your view objects collaborate with entity objects to consistently
validate and save the changes
What is view object & view link in Oracle ADF?
ADF View Object: ADF view object definitions are business components that
collect data from the data source, shape that data for use by clients, and allow
clients to change that data in the Oracle ADF Business Components cache. For
example, a view object definition can gather all the information needed to:
Populate a single table element in a form
Create and process an insert or edit form
Create an LOV for populating a dropdown list
View object definitions must have a mechanism for retrieving data from the data
source. Usually, the data source is a database, and the mechanism is a SQL
query. Oracle ADF Business Components can automatically use JDBC to pass this
query to the database and receive the result.
When view object definitions use a SQL query, query columns map to view
attributes in the view object definition. The definitions of these attributes reflect
the properties of these columns, such as the columns' data types and precision
and scale specifications. When view object definitions use other data sources,
view object attributes map to "columns" of data from those data sources, as
defined by the programmer.
A view object definition is a template for view object instances, which represent
particular caches of rows of data. Different users will always use different view
object instances, but the same user may also use multiple view object instances
if they need separately maintained caches from the same query.
A view object definition can have up to four parts:
An XML file, which represents the portion of the view object definition that can be
developed declaratively. This information consists of the mechanism (usually a
SQL query) that the view object uses to retrieve data from the data source, and
the way in which the columns of the SQL query map to entity attributes (which
handle actual O/R mapping). For many view object definitions, the XML file by
itself is sufficient.
A view object class, which represents an individual view object instance. View
object classes allow you to write custom methods that affect multiple rows in a
query. View object classes extend the classoracle.jbo.server.ViewObjectImpl. If
you do not need to write custom view object methods, you need not generate an
entity object classADF can use oracle.jbo.server.ViewObjectImpl directly to
represent instances of the query result set.
A view row class, which represents individual rows of the query result. View row
classes allow you to write custom methods that affect a single row of data, and
they provide typesafe accessors to retrieve and change data. View row classes
extend the class oracle.jbo.server.ViewRowImpl. If you do not need custom rowlevel methods or typesafe accessors, you need not generate a view row class
ADF can useViewRowImpl directly to represent view rows.
A view definition class, which represents the query itself. View definition classes
act as Java wrappers for the XML file, so if you need special handling of the
metadata (for example, if you need to change it dynamically), you can add this
code in the view definition class. View definition classes extend the
classoracle.jbo.server.ViewDefImpl. If you do not need custom handling of your
metadata, you need not generate a view definition classADF can use
ViewDefImpl directly to wrap the metadata.
1 Attribute Mappings
Like entity attributes, the values of view attributes can be read or changed using
the methods getAttribute() andsetAttribute() in the ViewRowImpl class or by
using generated getters and setters in a custom view row class.
There are two different types of view attributes, however, for which these
accesssor methods function quite differently:
SQL-only view attributes are not mapped to entity attributes. For these attributes,
the accessor methods read values from and make changes to data in the view
object instance's cache of view rows.
Entity-derived view attributes are mapped to attributes in an entity object
definition. For these attributes, the accessor methods will call getAttribute() and
setAttribute() on the relevant entity object instance. The data will be changed
within the entity collection's cache of entity object instances, not within the view
object instance's cache of view rows.
Because entity object definitions handle DML operations, attributes that will be
used to make changes to the database must be entity-derived. However, if a view
object definition will be used for data retrieval only, there is an advantage to
making all its attributes SQL-only: such view object definitions, called SQL-only
view object definitions, bypass the entity collection's cache entirely, avoiding the
overhead and resources required to create entity object instances.
2 Navigating Through Result Sets
View object instances are row iterators. In particular, they are row iterators of
view rows.
Like other row iterators, view object instances contain a current row pointer that
points to one particular view row. This pointer can be moved around and used to
extract rows from the iterator.
Row iterators contain a number of methods to help you navigate and extract
individual rows from them:
next() advances the current row pointer in the row iterator and returns that row.
hasNext() checks to make sure that the row iterator has more rows after the
current row pointer. You can use next() and hasNext() together to create a loop to
cycle through the rows in the iterator.
First() moves the current row pointer to the first row in the iterator and returns
that row.
Last() moves the current row pointer to the last row in the iterator and returns
that row.
Previous() steps the current row pointer back one row and returns that row.
hasPrevious() checks to make sure that the row iterator has more rows after the
current row pointer. You can use previous() and hasPrevious() together to create a
loop to cycle backwards through the rows in the iterator.
3 Creating and Deleting Rows
ViewObjectImpl also contains methods to create rows:
createRow() creates a view row appropriate to the view object definition.
insertRow() inserts the row into the view cache.
You can mark a row for deletion by calling Row.remove() or
ViewObjectImpl.removeCurrentRow().
4 Keys
A key is a set of attributes that allow you to quickly retrieve one or more rows
from a view object instance's query result. Persistent view object attributes based
on primary keys are automatically part of the view object's key; you can make
other attributes part of the view object's key as well.
You can use an array containing a partial or complete list of attribute values to
set up an object of typeoracle.jbo.Key. You can then pass this object into the
method ViewObjectImpl.findByKey() to return an array of rows that match the key
values.
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-byexample 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 and View Link Instances
Often, it is important to distinguish between the following:
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:
RowIterator details = current.getAttribute("DepartmentEmployees");
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.
To maintain a synchronized master-detail relationship, you should use view link
instances in an application module instance.
2 Cardinality:
Like associations, view link definitions can be one-to-one, one-to-many, or manyto-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.
Q: ADF 10g navigation rules example in faces-config.xml file.
Ans: Navigation rules tells JSF implementation which page to send back to the
browser after a form has been submitted. We can declare the page navigation as
follows:
<naviagation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
</naviagation-rule>
This declaration states that the login action navigates to /welcome.jsp, if it
occurred inside /index.jsp.
Q: Setting the range of table
A: <af:table rows=#{bindings.LoggedInUserServiceRequests.rangeSize}/>
Q : Which component in ADF BC manages transaction ?
A : Application Module, manages transaction.
Q : Where is that we write business rules/validations in ADF and why?
A : We should ideally be writing validations at Entity Object level, because they
provide highest degree of reuse.
Q : What are various components in ADF?
A : Oracle ADF has following components
ADF Business Components: VO, EO & AM
ADF Model : DataBinding (.cpx, .xml) & DataControls(.dcx)
ADF View: JSP, JSF, ADF Faces etc.
ADF Controller: Task flows (adf-config.xml), faces-config.xml
Q : What is the return type of Service Methods?
A : Service Methods can return Scalar or Primitive Data types.
Q : Can Service Methods return type Void?
A : Yes, Service Methods can Return type Void
Q : Can Service Methods return Complex Data types?
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
Another approach is to use SkipValidation property associated with the page
definition file.SkipValidation by pass the model layer validation based on the
specified parameter value.
Please note that:
1. This doesnt have any impact on JSF/ADF Lifecycle.
2. This property doesnt have any effect on the client side validation (even if it is
generated using the EL bound with model layer)
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
In this case, framework validates only the 'CustomValidator' specified in page
definition file.
The value of the 'CustomValidator' property would be an EL expression that
Scenario:
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.
1. A single entity is mapped to multiple tabs in a page.
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.
2.
Based on EO Association
WHERE :1 = ORDERS.CUSTOMER_ID
You could then use CustOrdLink conjunction with a row from CustomersView (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
Q. Can you make View Link bidirectional?
A: Yes, you can make a view link bidirectional.
Q: What are the security application layers & how they handled in Oracle ADF?Q:
What is policy store and identity store in OID?
A: Identity Store is used to store information about users and groups while the
Policy Store is used to store information about security policies.
Q : In which xml do you configure the skin for your framework application?
A: trinidad-config.xml
Q : How do you decide whether the application should be deployed as an EAR or
a WAR?
A: If the application contains run-time customizations using MDS, it must be
bundles as an EAR. For simple webcenter portal application with no such
customizations, WAR can be created.
Q : What is the purpose of jazn-data.xml?
A: This file is used for defining the permissions and privileges for various groups
of users on various taskflows created in the application.
Q : When we drag drop VO from DataControl which binding occurs?
A: Value binding occurs.
Q : Explain Data binding & its types, sub-types?
A : Oracle Application Development Framework (Oracle ADF) provides several
types of binding objects to support the attributes and operations exposed by the
Oracle ADF data controls for a particular business object:
Iterator binding, one per accessor attribute that your page or panel displays.
Iterates over the business objects of the data collection and maintains the row
currency and state.
Value bindings, one for each data-bound UI component. Provides access to data.
Action binding, specifically defined for a button component. Provides access to
operations defined by the business object.
Value Binding Types:
1. Attribute Value Binding
2. Boolean Value Binding
3. List Value Binding
4. Range Value Binding
5. Scroll Value Binding
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
DCBindingContainer dcbc = (DCBindingContainer) bc;
DCIteratorBinding lBinding = dcbc.findIteratorBinding("EmployeesViewIterator");
EmployeesViewRow row = (EmployeesViewRow) lBinding.getCurrentRow();
EmployeesView view = (EmployeesView) lBinding.getViewObject();
You have to change the iterator name 'EmployeesViewIterator' to the name of
your VO iterator (look it up in the page bindings) and the classes Employees.
Q: How many types of VOs we can create in Oracle ADF?
A: There are four types of VOs we can create as shown in below image, select
radio button & create VO.
Sometimes you need dynamic ViewCriteria that you can handle at runtime ,
here is the solution ,you can create and apply ViewCriteria ProgrammaticallySample UseCaseSuppose you have Department VO
You want to filter this VO for DepartmentId 10
Do this using this code snippet
/**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();
pcAMImpl am = (pcAMImpl)resolvElDC("pcAMDataControl");
return am;
}
Q: How can you manage transaction in ADF?
A: We can manage transaction using Application Module, different Application
Modules, Bounded Task Flows & at ADF Data Control Level.
7 View comments
Reply
Loading