Sunday 1 May 2016

ADF Interview Questions - Set 11

Question: How to connect standalone weblogic instance from jdeveloper? How to deploy application to standalone weblogic instance from jdeveloper?

Answer: To demonstrate deployment directly from JDeveloper, let's create a sample Fusion Web Application (Web) based on the HR schema. Let's create an Employee entity from the EMPLOYEES table and an Employees view based on the Employee entity. Finally, let's bundle the Employees view in the HrAppModule application module.

For the ViewController let’s create a View Activity called Employees directly in the unbounded adfc-config task flow and anEmployees.jspx JSF page for the Employees View Activity. Finally, let’s drag the Employees view from theHrAppModuleDataControl in the Data Controls and drop it onto the Employees.jspx JSF page as an ADF Form.

In order to deploy our application, we first need to create an Application Server Connection to the standalone WebLogic server. First let’s start WebLogic if not yet started. Then, in the Resource Palette (View Resource Palette) let’s create a new Application Server connection. 



In the Create Application Server Connection wizard Name and Type page specify the Connection Name, ensure that the Connection Type is set to WebLogic 10.3 and click Next


  
In the Authentication page specify the WebLogic server Username and Password


  
In the Configuration page specify the WebLogic Hostname – localhost for our development machine, the server Port – defaults to 7001 - and the Weblogic Domain name that we will be deploying on. 

  

  
In the Test page click on the Test Connection button to test the connection and verify that all tests are successful. 
  
Click Finish to save the connection which will appear in the IDE Connections in the Resource Palette
  
Now we are ready to deploy our application. From the Application Menu – at the top left next to the application selection – select Deploy… and then the name of the deployment. 

  
The first time around a Deployment wizard will be displayed. In the Deployment Action page select Deploy to Application Server and click Next.

In the Select Server page select the application server connection we created earlier from the listed Application Servers. Uncheck the Deploy to all server instances in the domain option if you want to deploy on a specific server instance. Leave the Deploy as a standalone Application option selected and press Next.


If you unchecked the Deploy to all server instances in the domain option in the previous page, a Server Instances page will be displayed. Select the Server instance that you will be deploying – ensure that the status of the server instance is RUNNING– and click Next.

In the Summary page verify the Deployment Summary details and click Finish to start the deployment process. The status of the deployment process is displayed in the Deployment – Log window. The deployment process first creates the Web Application Module (war), then the Enterprise Application Module (ear) and finally deploys the application onto the server instance(s). If all goes well the message Application Deployed Successfully is shown in the log window.
  

That’s it. Our application has been deployed into the standalone WebLogic server. To verify that this is the case, log in into the WebLogic administrator console – http://localhost:7001/console - and click Deployments in the Domain Structure tree. In the Summary of Deployments you should see the application we’ve just deployed.



We can access our deployed application by entering the application URL –http://127.0.0.1:7001/JDeveloperFAQNo3/faces/Employees - on the browser. At this point the application won't initialize and the Employees page won’t load until we enable security in our application. We will see how to do that some other time.

Conclusion: Once we install and configure the standalone WebLogic server in our development machine, deploying an ADF application directly onto it from JDeveloper is a piece of cake. Just make a connection to the server in JDeveloper and deploy! 



ADF Interview Questions - Set 10

Question: How to run application with -Djbo.debugoutput=console enabled in JAVA options?
Answer: Right click on project -> open project properties -> Select Run/Debug/Profile option and click on Edit -> Give -Djbo.debugoutput=console  in Java Options -> Click Ok.

Question: Can you use view object inside custom component definition?
Answer: Use of datamodel inside the Declarative components is not allowed by adf. But there is work around for that you can pass you iterator to Declarative component. You have to write the logic to get data from iterator and display on component same logic you can use to retrieve data from component and set that to iterator.

Question: What is view object?
Answer: A view object is a model object used specifically in the presentation tier. It contains the data that must display in the view layer and the logic to validate user input, handle events, and interact with the business-logic tier. The backing bean is the view object in a JSF-based application. Backing bean and view object are interchangeable terms

Question: What is a view scope?
Answer: 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.

Question: What do you mean by Bean Scope?
Answer: Bean Scope typically holds beans and other objects that need to be available in the different components of a web application.

Question: Can you use view object inside custom component definition?
Answer: Use of data model inside the Declarative components is not allowed by adf. But there is work around for that you can pass you iterator to Declarative component. You have to write the logic to get data from iterator and display on component same logic you can use to retrieve data from component and set that to iterator.

Question: Which file holds the details of users and groups in adf?
Answer: Users and Groups we usually create in Security part at the time of enabling security on your application by default some of the files gets created inside Application Resources, Inside that we will find jazn-data.xml file, once we open that file we can have access to create the user profiles, Application Roles and Enterprise roles, So your application level roles is assigned to the users whomever are created in your user profile, So each and everything from user roles to enterprise roles you are giving inside your jazn-data.xml file.

Question: Explain about JSF lifecycle.
Answer: A typical JSF lifecycle flows as follows:
1.     JSF interrogates the request to extract the incoming parameters.
2.     JSF converts these parameters from strings to their corresponding data types.
3.     JSF validates the presence of required parameters, the correctness of entered values, etc.
4.     JSF uses the incoming URL to determine who should process the request. This is usually done using post-backs.
5.     JSF will execute any custom logic that you provide it. Your logic will store work products (or Transfer Objects for the view) in the appropriate scope. JSF defines interfaces for event handlers and clear guidelines as to when a particular handler will be invoked.
6.     JSF determines the view that will display the response to the user. JSF uses the return value of your application handler to look up the desired view in a mapping file that you provide.
7.     JSF will execute any custom logic that you provide to render your response, or will forward to the desired view.

During all of this, JSF provides utilities for errors to be exposed to the user, for internationalization using resource bundles, etc. JSF does not provide a native composition facility - so you'll need to include Tiles or Facelets.


Question: How to declare the page navigation (navigation rules) in faces-config.xml file in ADF 10g?
Answer: 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.

Question: How to set the range of a table?
Answer: <af:table rows=”#{bindings.LoggedInUserServiceRequests.rangeSize}”…/>

Question: What is region in Task Flow?
Answer: You can render a bounded task flow in a JSF page or page fragment (.jsff) by using an ADF region. An ADF region comprises the following. You create an ADF region by dragging and dropping a bounded task flow that contains at least one view activity or one task flow call activity to the page where you want to render the ADF region. This makes sure that the ADF region you create has content to display at runtime

Question: What is Backing Bean?
Answer: Backing beans are JavaBeans components associated with UI components used in a page. Backing-bean management separates the definition of UI component objects from objects that perform application-specific processing and hold data.
Backing beans are those managed beans which have 1:1 mapping with a page. They have getters and setters for all the components in the related page.

Backing bean is about the role a particular managed bean plays. This is a role to be a server-side representation of the components located on the page. Usually, the backing beans have a request scope, but it is not a restriction.
The backing bean defines properties and handling-logics associated with the UI components used on the page. Each backing-bean property is bound to either a component instance or its value. A backing bean also defines a set of methods that perform functions for the component, such as validating the component’s data, handling events that the component fires and performing processing associated with navigation when the component activates.

ADF Interview Questions - Set 9

Question: What is user customization?
Answer: Term personalization means user can perform changes visible only to that user. Term customization means user with admin privileges can perform global changes, visible to all users. You can achieve personalization functionality within standard ADF framework enabled with MDS. For customization functionality need to use Oracle WebCenter component - Composer.
UserCC class retrieve current user name from security context:



As per documentation, I have created all required Java classes to support Edit and View layers:


User customization and personalization are enabled to be stored across sessions with MDS. This option is needed to store changes for ADF components; Oracle WebCenter Composer is working without this option as well:


I have change customization class from SiteCC to UserCC, this enables personalization:


Session options factory is class must be configured in adf-config.xml to enable customization:


As per documentation, additionally you need to declare Oracle WebCenter Composer servlet in web.xml.
ADF Security defines two application level roles - admin and customer. Admin role is granted with Customization permission:


Session options factory class as per documentation defines two layers - Edit and View. You can see that Edit layer is applied on global level (it’s when Oracle WebCenter Composer is invoked to perform customization). View layer is applied on global and user levels (this means each user will see global customizations and their own personalization):

If Oracle WebCenter Composer is On, Edit layer is enabled, otherwise - View layer:



ADF Interview Questions - Set 8

Question: What is Query Collection in VO?
Answer: Query Collection is mainly used for caching the result of the executed query VO. A VO can have multiple query collections depending on the rowsets.
Example: If we have 2 rowsets where DEPTID =10 and DEPTID=20. So the results of the executed VO with these bind variables are stored in Query Collection.
Now we understood what are the other layers that are to be used before hitting the data source? Now let us see how it will be executed with an example: 

Example:  Let’s consider a java code snippet where we execute a VO and retrieve the values 
          ViewObject vo = ApplicationModule.findViewObject(“EmployeesVO”);
           vo.executeQuery(); 
           Row row = vo.first();                                          // gets the first row
     Steps involved in executing this VO are as follows: 


1.     ADF client starts interaction with the Application Module. 
2.     ADF Client looks for the requested View Object (EmployeesVO) instance in AM.
3.     Now before executing the VO, it does as below: 
a.     Checks for relevant Query Collection for Search Parameters (Bind Variables), if available uses the existing query collection.
b.    If not present created a new Query Collection based on the Search Parameters.
4.     Once the QC is initialized, the new Rowset instance calls the prepareRowSetQuery() on VO. This is used for placing your customcode before Querycollection. (Eg: the Query for the rowset with the bind variable).
5.     This is followed by executeQueryForCollection(), which delegates the call for query collection instance and JDBC call for particular Database. 
6.     Now when a client tries to get the first row in result set by calling first() , as the result set retrieves the first row it displays the first row.

Question: How and When Groovy Expression is used?
Answer: Groovy is interpreted at runtime; it can be treated as metadata and customized. So, you could have an application that has customized business rules in Groovy and those customizations stored in Oracle ADF’s Metadata Services (MDS).
Oracle ADF provides a number of different declarative points into which you can drop Groovy code:
1.     Values for view and entity objects attributes
2.     Validation rules on entity object attributes
3.     Expressions for error messages
4.     Values for view object bind variables
5.     View object transient attribute validation.
Examples:
1: For the transient attribute AnnualSalary you could define a Groovy expression for the default to be: Sal * 12
2: On the Sal attribute you might want to define that a salesman must have a salary of less than 1000: if (Job == "SALESMAN") {return newValue < 1000} else return true.

ADF Business Components view objects also provide the ability to use Groovy expressions. As with entity objects, view objects can support:
1.     Referencing attributes in the same view object
2.     Referencing attributes in other view objects
3.     Transient attribute validation
4.     Referencing methods in the Java class that backs the view object
5.     Referencing built in calls such as sum and min.

Question: What are the steps to configure MDS? What are different kinds of MDS you configured? Which file hold details of configured MDS?
Answer: To apply MDS to your application follow this:
1. Pages should be (.jspx) not (.jsp).
2. In your project properties --> ADF View check on "Enable User Customizations" then select "Across Sessions Using MDS".
3.Create a new class as below. This class has two main functions:
- getName() which return the folder name that hold all users changes.
- getValue() which return the folder name for the login user. This folder should be unique for every login user and will saved inside the getName() folder.


4. In Application Resources --> Descriptors --> ADF META-INF open adf-config.xml.
5. In adf-config file go to MDS Configurations and add your class


6. In adf-config file go to View tab and add all Tags.

7. Now you apply MDS to your application.
8. If you run your application in Integrated Weblogic there will be no problem, you should only specify the path to store the user changes (changes will stored in file system). You will find this path in your Application properties --> Run --> MDS.

ADF Interview Questions - Set 7

Question: Explain briefly the life-cycle phases of JSF?
Answer: The six phases of the JSF application lifecycle are as follows:
1. Restore View: A request comes through the FacesServlet controller. The controller examines the request and extracts the view ID, which is determined by the name of the JSP page.
2. Apply request values - process events: The purpose of the apply request values phase is for each component to retrieve its current state. The components must first be retrieved or created from the FacesContext object, followed by their values.
3. Process validations - process events: In this phase, each component will have its values validated against the application’s validation rules.
4. Update model values - process events: In this phase JSF updates the actual values of the server-side model ,by updating the properties of your backing beans.
5. Invoke application - process events: In this phase the JSF controller invokes the application to handle Form submissions.
6. Render response: In this phase JSF displays the view with all of its components in their current state.

Question: Write code to access the current row and or the view object inside your bean?
Answer: 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();

Question: What is Action Listener?
Answer: 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.

Question: What are mutable and immutable objects?
Answer: An immutable class is immutable, as in, it is not mutable. You cannot change it. If you have x::String, you can be absolutely 100% certain that x will never ever change ever (or at least, if it does, people are abusing the flexibility of your language and you have every right to tell them where to go).
A mutable class is not immutable. You can change it, other people can change it, and you can't rely on it being the same. It could be changed in another thread; you can't even be sure of it being in the same state from line to line unless you have good locking.
Question: What is Application module pooling and how can we handle it?
Answer: An application module pool is a collection of application module instances of the same type, such as an Orders application module or a Human Resources application module. This pool of application module instances is shared by multiple browser clients. The amount of time between submitting Web pages enables a smaller number of application module components to serve a larger number of active users. This reduces memory usage and improves performance.
This facility manages a configurable set of application module instances that grows and shrinks as the end-user load on your application changes during the day.
At any one time, the pool may contain application module instances that are partitioned into
three groups, based on their state. When the processing of a current HTTP request completes, the application module instance is checked back into the pool. If the AM instance has managed state, the pool keeps track that the AM is referenced by that particular session.
For example – We have pool of 5 Application module instances. After having request from multiple browsers, request will go to instance, which is available for time being. We have 3 state defined for appModule instances –
1- Available
2- Partially available- but referenced for preferred reuses by another active session that would be more efficient due to the managed state of the application module.
3- Unavailable- because it is being used at that very moment by a Web container thread

Note: Pools are created only for root application modules, not for nested ones that users access indirectly through a root application module.
In short –
Application module pooling:
• Enables users to share application modules
• Manages application state
• Provides the same instance or one with an identical state
when requested by an application with managed state

Question: How can we prevent unauthorised access to the ADF DC Model?
Answer: By using Bounded Task Flow

Question: How can we share AM for using same transaction?
Answer: By using AM Module Pooling.

Question: What are the MDS (Metadata Services)?
Answer: Metadata Services (MDS) is a feature provided by oracle to store customization and personalization information in a repository. The repository can either be stored in a database or in a file system as we will see.

For example if a screen has a table, this table has 8 columns, and there are a user (User1) want to see only 4 columns and hide the others. When User1 login again he want to see last changes which he make (see only 4 columns), the user can see any changes he make in the screen only if you apply MDS to your application.