Monday, March 26, 2018

Oracle ADF UI & Data Visualization Components Interview questions and answers

Q: What are the ADF templates, jspx pages, jsff page & declarative components?
A: ADF Faces provides the following types of reusable building blocks



  • Page fragments(.jsff): Page fragments allow you to create parts of a page. A JSF page can be made up of one or more page fragments. For example, a large JSF page can be broken up into several smaller page fragments for easier maintenance. 
    We can create an page fragments template & use to create page fragments.

  • Page templates (.jspx): By creating page templates, you can create entire page layouts using individual components and page fragments. For example, if you are repeatedly laying out some components in a specific way in multiple JSF pages, consider creating a page template for those pages. When you use the page template to build your pages, you can be sure that the pages are always consistent in structure and layout across the application. 
    Using default layouts or creating new we can create page templates.
    Ex. Using <f:facet> we can create page templates with header, footer, top, left & right regions etc. 

  • Declarative components: The declarative components feature allows you to assemble existing, individual UI components into one composite, reusable component, which you then declaratively use in one or more pages. 
    For example, if you are always inserting a group of components in multiple places, consider creating a composite declarative component that comprises the individual components, and then reusing that declarative component in multiple places throughout the application. 
    Declarative components can also be used in page templates. 
    Declarative components can also be used in other applications, its possible after creating JAR file of that component.


  • Q: What is region in Oracle ADF?
    A: Tag name : <af:region>

    The region tag allows dynamic content to be included in a master page. This tag is bound to a RegionModel. The model decides which viewId is to be included. The model has methods that allow pre and post processing of an include. See the javadoc for oracle.adf.view.rich.model.RegionModel. 

    This component does not support any facets. 
    Regions support nesting (one af:region component can contain another af:region component). 
    Regions are not allowed to be placed inside of af:forEach, c:forEach, or other forEach-like tags because of limitations in how JSF handles component IDs and component state which would manifest in your application in obscure manners such as loss of component state. 
    Regions are also not allowed to be placed inside of af:iterator because the region requires bindings to be established at the tag execution phase in order to perform its JSP include operations and the variables for iterators are not established until later in the life-cycle.

    Regions in release 11g are reusable page flows. They have their own navigation rules, managed beans and ADFm page definitions. Each page within the region is a page fragment (jsff). Do not confuse the 11g af:region component with the 10.1.3 or Trinidad region. The 10.1.3 and Trinidad region components are single page fragments that do not have multiple pages, navigation rules nor managed beans. The 10.1.3 region is similar to the 11g page templates and declarative components.

    The <af:region> will not stretch all included children, but it will stretch an included child if all of the following are true:
    • The region itself does not have a header
    • The region itself is being stretched
    • There is only a single included child
    • The child must be capable of being stretched
    Example<af:region value="#{mybean.myRegionModel}"/>

    Q: What is <f:facet> ?
    A: This tag is used to add a facet to the component means this tag is used to add its child as a facet of the closest parent component.
    With the help of this tag we can add header and footer facet to the container component like panelGroup.

    This tag contains one attribute :
    name : This is the required attribute and is used to set the name of the facet. "header" and "footer" values can be used for this attribute.


    Q : How to skip validation in ADF?
    A : Add immediate="true" to the button. This way all input fields which don't have immediate="true"will be skipped in processing.
    This method mainly used for view layer validation skip.

    Q : How to make any field mandatory?
    A : Add attribute required="true" to that specific field.

    Q: What is setActionListener?
    Ans: SetActionListener – The setActionListener tag is a declarative way to allow an action source ( , , etc.) to set a value before navigation. It is perhaps most useful in conjunction with the “processScope” EL scope provided by ADF Faces, as it makes possible to pass details from one page to another without writing any Java code. This tag can be used both with ADF Faces commands and JSF standard tags.
    Exmaple of this can be as follows. Suppose we have a table “employee”.We want to fetch the salary of an employee of some particular row and want to send this salary in Next page in process scope or request scope etc.So using this we can do this.

    It have two attributes :

    From – the source of the value; can be an EL expression or a constant value

    To – the target for the value; must be an EL expression
    1<af:setActionListener from="#{row.salary}"
    2to="#{processScope.salary1}"/>

    This setActionListener will pick value of salary of that row and store this value into salary1 variable.So anyone can use this salary as processScope.salary1.
    It is very simple to use and very useful.

    Q: How to pass Values Between Pages?
    A: The ADF Faces pageFlowScope scope makes it easier to pass values from one page to another, thus enabling you to develop master-detail pages more easily. Values added to thepageFlowScope scope automatically continue to be available as the user navigates from one page to another, even if you use a redirect directive. But unlike session scope, these values are visible only in the current page flow or process. If the user opens a new window and starts navigating, that series of windows will have its own process. Values stored in each window remain independent.
    Like objects stored in any standard JSF scope, objects stored in the pageFlow scope can be accessed through EL expressions. The only difference with the pageFlow scope is that the object names must use the pageFlowScope prefix. For example, to have a button's label provided by a managed bean stored in the pageFlow scope, and to have a method on the bean called when the button is selected, you might use the following code on your page:
    <af:commandButton text="#{pageFlowScope.buttonBean.label}"
                      action="#{pageFlowScope.buttonBean.action}"/>
    
    The pageFlowScope is a java.util.Map object that may be accessed from Java code. The setPropertyListener tag allows you to set property values onto a scope, and also allows you to define the event the tag should listen for. For example, when you use the setPropertyListener tag with the type attribute set to action, it provides a declarative way to cause an action source (for example, commandButton) to set a value before navigation. You can use the pageFlowScope scope with the setPropertyListener tag to pass values from one page to another, without writing any Java code in a backing bean. For example, you might have one page that uses the setPropertyListener tag and a command component to set a value in the pageFlowScope scope, and another page whose text components use the pageFlowScope scope to retrieve their values.
    You can also use the pageFlowScope scope to set values between secondary windows such as dialogs. When you launch secondary windows from, for example, a commandButtoncomponent, you can use a launchEvent event and the pageFlowScope scope to pass values into and out of the secondary windows without overriding values in the parent process.

    Tip: Instead of using the setActionListener tag (which may have been used in previous versions of ADF Faces), use the setPropertyListener tag and set the event type to action.

    Q: How to Use the pageFlowScope Scope Within Java Code

    A: You can access pageFlow scope from within any Java code in your application. Remember to clear the scope once you are finished.


    Note: If your application uses ADF Controller, then you do not have to manually clear the scope.

    To use pageFlowScope in Java code:
    1. To get a reference to the pageFlowScope scope, use the org.apache.myfaces.trinidad.context.RequestContext. getPageFlowScope() method.
      For example, to retrieve an object from the pageFlowScope scope, you might use the following Java code:
      import java.util.Map;
      import org.apache.myfaces.trinidad.context.RequestContext;
      . . .
      Map pageFlowScope = RequestContext.getCurrentInstance().getPageFlowScope();
      Object myObject = pageFlowScope.get("myObjectName");
      
    2. To clear the pageFlowScope scope, access it and then manually clear it.
      For example, you might use the following Java code to clear the scope:
      RequestContext afContext = RequestContext.getCurrentInstance();
      afContext.getPageFlowScope().clear();
    Q. How to pass ''af:selectOneChoice'' value to other page?
    A: Add valuePassThru="true" attribute to select list. 

    Q. What are types of ADF Faces components?
    A: ADF Faces components:
    Data components
    Input components
    Layout components
    Navigational components
    Output components

    Q. Why 'timeZone' attribute is required when <af:convertDateTime is used?
    A: When <af:convertDateTime is used it takes by default GMT time, for Indian timing we need to take GMT+5.30
    EX.
    <af:inputText id="compId3882"
                                                label="#{messageBean['SS_DATE_OF_BIRTH']}"
                                                disabled="true" maximumLength="50"
                                                value="#{bindings.DateofBirth.inputValue}"
                                                inlineStyle="font-size:smaller; font-weight:normal; font-    
                                                family:Arial;color:rgb(69,69,69);">
       <af:convertDateTime timeZone="GMT+5:30" pattern="dd/MM/yyyy"/>
     </af:inputText>

    Q: What is the difference between trinidad.config and trinidad.skins?A: trinidad.config file is ceated when you create a webcenter portal application. This is used to register the skin-family you are going to use for your entire application. Trinidad.skins is used when we use skin as a Jar file. This file provides a mapping between the Skin Id and the actual path where the skin exists.

    Q: What is the difference between an action and an action listener?
    A: Actions are designed for business logic and participate in navigation handling, whereas action listeners typically perform user interface logic and do not participate in navigation handling.
    Action listener is a class that wants to be notified when a command component fires an action event.
    Action returns String ActionListner returns void.
    • Action used for page navigation with faces-config.xml or adf-config.xml, ActionListner is used for event handling, to retrieve data & other operations, its used with backing beans or bindings.
    • Action use - for page navigation, ActionListner use - check box, drop down box.
    Q: What is a view scope?
    A: view-state allocates a new viewScope when it enters. This scope may be referenced within the view-state to assign variables that should live for the duration of the state. This scope is useful for manipulating objects over a series of requests from the same view.

    Q: What is the difference between visible property and render property
    A: The visible property is set to true/false based on the requirement whether we want to see the field on the page or not at run time. The field or component still exists on the page, though hidden. The render property is used to conditionally load the component based on a criteria.

    Q: How do you define pagination in adf?
    A: It was not possible to do 
    pagination on af:table component before R1 release 11.1.1.7, although this feature was exist in 10g but not available in previous 11g series. (Ref blog - Click here..)

    In 11g series there were some customization approach for pagination: 
    1. We define custom pagination in ADF by creating a custom table as a taskflow using the af:iterator tag. This renders the collection of data just as a table renders it. Now we bind the value property of iterator to collection model from ADF bindings declaration and set the number of visible row to, say 15.
    2. Using JavaScript
    3. Customizing VO java code,

    Q: What are validators and converters?
    A: Validators and Convertors are used to provide conversion and validation capabilities to the ADF input components respectively. Converters convert the valurs on ADF forms to the type in which the application accepts them after the values are edited on the form and submitted. Validators re used to impose validations on the inpiut components.

    Q: What is the difference between setting an immediate=true on a button and immediate=true on a text field?A:  When immediate is true on a button, the command’s action and ActionListeners, including the default ActionListener provided by the JavaServer Faces implementation, will be executed during Apply Request Values phase of the request processing lifecycle, rather than waiting until the Invoke Application phase.

    In case of a text field, by default, values are converted and validated together in the Process Validators phase. However, if you need access to the value of a component during Apply Request Values – for example, if you need to get the value from an actionListener on an immediate commandButton – then setting this to “immediate” makes that possible.

    Q: What is inter-portlet communication?
    A: Inter-portlet communication is achieved when an action in one portlet triggers a response in the second portlet. Its a communication bridge between two portlets. For eg, one portlet contains a checkbox containing list of products. When i choose a product from the list and click on submit, the other portlet displays the details of the respective product.

    Q. How to do table pagination in Oracle ADF?
    A: This feature has brought back from 10g to new R1 release 11g-PS6 (10.1.1.7.0)
    Go through blog: Click here..

    Q: How To Control ADF Table Pagination on Runtime and Do Case Insensitive Search?
    A: Go through blog: Click Here..

    Q : What is PPR and how do you enable Partial Page Rendering(PPR)?
    A : PPR is a feature supported by ADF Faces, using which we can render a small portion of a HTML Page, without refreshing the complete page.
    It is enabled by.
    - Setting AutoSubmit property to true on the triggering element.
    - Setting the PartialTriggers property of target component to refer to component id of the triggering element.

    Q : Explain Iterator RangeSize Attribute
    A : Iterator bindings have a rangeSize attribute that the binding uses to determine the number of data objects to make available for the page for each iteration. This attribute helps in situations when the number of objects in the data source is quite large. Instead of returning all objects, the iterator binding returns only a set number, which then become accessible to the other bindings. Once the iterator reaches the end of the range, it accesses the next set. 
    Example shows the default range size for the CustomerInfoVO iterator.
    Example RangeSize Attribute for an Iterator
    <iterator Binds="CustomerInfoVO" RangeSize="25" DataControl="StoreServiceAMDataControl" id="CustomerInfoVO1Iterator"
    ChangeEventPolicy="ppr"/>

    By default, the rangeSize attribute is set to 25.
    You can set it to -1 to have the full record set returned.

    Oracle ADF Interview Questions


    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 *.cpxfileextension 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 user’s 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 page’s 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 pageand 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 class—ADF 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 row-level 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 class—ADF can use ViewDefImpl directly to wrap the metadata.
    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.

    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.
    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().

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

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

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

    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?
    A : No, service methods can return only primitive/scalar data types.

    Q : Where do we write business rules or validations in ADF and why?
    A : We should be writing validations at Entity Object level, because they provide highest degree of reuse.

    Q : What are the various access scopes supported by ADF?
    A : ADF Faces supports the following scopes
      • backingBean
      • request
      • view
      • pageFlow
      • session
      • application

    Memory Scope for ADF Managed Beans

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


    Q : How to Skip Validation in ADF using SkipValidation?

    A : This method mainly used for Model layer validation skip.
    ADF has a very robust validation framework. Validations can be added at different layers (view, model and business services) based on your application's requirement. To learn more about the ADF validation framework, please go through the Fusion Developer's Guide for Oracle Application Development Framework.
    That said, however, in a real business scenario there are cases where the validation needs to be skipped (or by passed) conditionally while submitting the form. This post discusses this topic with some common use cases.

    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 doesn’t have any impact on JSF/ADF Lifecycle.

    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)


    Where can I locate SkipValidation?

    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

    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 evaluates to a bean that implements the "oracle.binding.BindingContainerValidator interface"



    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.

    Q.What are Entity Objects?
    A: Entity objects are Data Access Objects (DAOs) that are responsible for persisting & caching data, validation, and encapsulating business rules.
    ·  Represent a database table or other data source.
    ·  Handles database caching.
    ·  Contains attributes representing the database columns.
    ·  Encapsulates attribute-level and entity –level validation logic.
    ·  Can contain custom business methods.

    Q : Can an entity object be based on two Database Objects(tables/views) or two Webservices?
    A : No, Directly its not possible to create EO using multiple tables.
       Entity objects will always have one to one relationship with a database   object or web service.   
         But using views you can create Entity Objects on multiple tables.

    Q.What is Control Hints in Entity Object configuration?
    A: Control hints are associated with the current view or entity attribute. All view objects inherit the hint values at run time.
    Control hints for data controls and bindings, including: Labels, Date & currency formatting.

    Q.What are View Objects?
    A: View objects, which can be bases on entity objects/Web Services,represent the data which you want to view and manipulate.
    ·  Present a view or slice of business data.
    ·  Are used for joining, filtering, projecting, and sorting your business data.
    ·  Can be based on any number of entity objects.
    ·  Can also be constructed from a SQL statement.
    Read-only SQL –Based View Objects:
    ·  Is not based on any entity based object.
    ·  Cannot be used for insert, update, or delete.
    .  Use SQL-based view objects for query –only views, which do not need the functionality of entity objects.

    Q.What is Application Module?
    A: An ADF components application module is a service object that coordinates view objects for a specific task in the same way that a form usually encapsulates a single user task. It contains only the business services that the application requires, and can be compared to a Forms module.
    An application module can represent and assist with tasks such as:
    ·  Updating customer information
    ·  Creating new order
    ·  Processing salary increases. 

    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 

    View Links and Queries
    A view link definition relates two view object definitions. In the vast majority of cases, the view object definitions will contain SQL queries that access a database, and the view link definition will relate those queries using a parametrized WHERE clause, which is appended to the destination view object's query and resolved using the values of source attributes.

    For example, suppose you had the following view object definitions:

               ·  CustomersViewcontaining the query:
    SELECT * FROM CUSTOMERS

    OrdersViewcontaining the query:
    SELECT * FROM ORDERS

    You could create a view link, CustOrdLink, with
    ·         CustomersView's CustomerId attribute as its source attribute
    ·         The parametrized WHERE clause
    WHERE :1 = ORDERS.CUSTOMER_ID

    You could then use CustOrdLink conjunction with a row fromCustomersView (for example, the row for Customer 101) and all ofOrdersView 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.
    It’s handled by view link query.
    View Links created on Association are also bidirectional.
    
    
    Q. How to create read only VO?
    A: While creating View select below marked option
    A view is read-only if it does not have Primary Keys or if all its entity
    references are reference-only.

    Q. Is EO to EO association possible like VO? If yes how?
    è  Direct EO-EO association is possible.
    In Jdeveloper select option ‘New Association’, Give name to association, select attributes in source & destination Eos.
    1.    One-to-many relationships based on foreign keys.
    2.    A single many-to-many association corresponds to two foreign key relationships:
    ·   A one-to-many relationship between the source table and a third table, the intersection table
    ·    A one-to-many relationship between the destination table and the intersection table.
                                 
                
    Q. What is Control hint?
    A: Control hints are additional attribute settings that the view layer can use to automatically display the queried information to the user in a consistent, locale-sensitive way.

    JDeveloper manages storing the hints in a way that is easy to localize for multi-lingual applications.

    Used to set: Parameters in screenshot

    Ex. Number, Number format, Date Format etc.

    Q: What are UI Hints & List UI Hints?
    A:
    UI Hints: VO -> Query -> Create or Edit view criteria -> click Tab UI Hints
    Use to specify the default properties for a query search component’s runtime usage of individual named view criteria. Named view criteria that you create for view object collections can be used by the web page designer to create query-by-example search forms.

    List UI Hints: Open view-object -> List UI Hints
    Use to specify default LOV (list of values) hints when you want the LOV-enabled attributes of other view objects to inherit the list UI hints from the current view object. Use to specify the type of LOV (list of values) component and one or more attributes to display in the LOV for the attributes that you will LOV-enabled. Additionally, you can set properties of the LOV component to customize it behavior in the user interface.


    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: What is the difference between databindings.cpx and datacontrol.dcx?
    A: The DataBindings.cpx file contains the Oracle ADF binding context for your entire application and provides the metadata from which the Oracle ADF binding objects are created at runtime. 
    The DataControls.dcx file is created when you register data controls on the business services. This file is not generated for Oracle ADF Business Components. It identifies the Oracle ADF model layer data control classes(factory classes) that facilitate the interaction between the client and the available business service.
     
    Q: What is binding context and binding container?
    A: Binding context is a runtime map between the data controls and page definition of pages in the application which is used to access the binding layer. It is accessible through the EL expression in your jspx pages. 

    Binding container is a request-scoped map that is used to instantiate the page bindings. This is accessible through the EL expressions. Also, since it is request-scoped map, it is accessible during every page request.

    Q: What are the different types of bindings in ADF?
    A: ADF contains the following types of bindings: 

    Method Bindings: This binding is used when you want to use custom methods to be executed.

    Attribute Bindings: This is the binding to retrieve the value of a single view attribute in the iterator binding’s current view row. For eg; #{bindings.CustomerId.InputValue}

    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}

    Action Bindings: This binding type is used when buttons or command links are dropped on the user interface and require an action to be performed on them. We can use data control operations on them, for eg, Create, Delete, First, Last, Commit, Rollback etc.

    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.

    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?
    A : No, service methods can return only primitive/scalar data types.

    Q : Which component in ADF BC manages transaction ?
    A : Application Module, manages transaction.

    Q : Can an entity object be based on two Database Objects(tables/views) or two Webservices ?
    A : No entity objects will always have one to one relationship with a database object or web service.

    Q : Where is that we write business rules/validations in ADF and why?
    A : We should be writing validations at Entity Object level, because they provide highest degree of reuse.

    Q : What are the various access scopes supported by ADF?
    A : ADF Faces supports the following scopes
        Application Scope
        Session Scope
        PageFlow Scope
        Request Scope
        BackingBean Scope.

    Q : What is the purpose of adfc-config.xml?
    A: The adfc-config.xml file is the configuration file for an ADF unbounded task flow. This file contains metadata about the activities and control flows contained in the unbounded task flow.

    Q : What is the purpose of faces-config.xml?
    A: Use the faces-config.xml file to register a Framework application’s resources, such as custom validators and managed beans, and to define all page-to-page navigation rules.

    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


    Q: Explain Data Control Palette hierarchy
    A: Data Control Palette hierarchy:The Data Control Palette displays two types of actions:
    • Actions that typically operate on all data collections in the current web page's binding context (such as Commit and Rollback) in the Operations folder at the root level of the hierarchy.
    • Operations on a specific data collection (for example, MyView1). Data collection-specific operations (such as Create and Delete) appear in the Operations folder as child nodes of the collection in the Data Control Palette.
    Q: Write  code to access the current row and or the view object inside your bean.

    A:  code to access the current row and or the view object inside your bean:

    
    
    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.


    1. Updatable VO (Updatable access through entity objects) - Here EO need to be created for  updatable VOs.
    2. Read only VO (Read-only access through SQl query) - No need to create EO, VOs can be created using SQL queries, table, or views.
    3. Rows populated pro-grammatically, not based on query - This is also read-only view. Here add one or more attributes to use in program. In the Attribute Settings page, adjust any setting you may need to for the attributes you defined.
    4. Static VO (Rows populated at design time- Static List): You use the Create View Object wizard to create static view objects. The wizard lets you define the desired attributes (columns) and enter as many rows of data as necessary. The wizard displays the static data table as you create it.

    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.

    View criteria is like querying a SQL query.

    Sometimes you need dynamic ViewCriteria that you can handle at runtime ,
    here is the solution ,you can create and apply ViewCriteria Programmatically-

    Sample UseCase-

    • Suppose 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();


      public pcAMImpl getAm() {
      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. 

    Q: What is Bundled Exception Mode in ADF?
    A: An application module provides a feature called bundled exception mode which allows web applications to easily present a maximal set of failed validation exceptions to the end user, instead of presenting only the first error that gets raised. By default, the ADF Business Components application module pool enables bundled exception mode for web applications.

    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.