How to create LOV in ADF 11g

Hi,

This week we will be learning how to create LOVs in Oracle ADF application.

Pre-requisites:
– HR Schema in Oracle database.
– I am using Jdeveloper 11.1.3

Objective:
On this post we will create LOV for Department Id in Simple Employee based form.

Steps to follow:

Adding Department Entity:

– Add Departments Entity by Right clicking on Vinay.model package in Model project and choose New Entity Object
Enter Name as ” Department ” and Choose Schema object as ” Department ” by pressing Browse button you can select from the list of objects as well.

Right click on Vinay.model.view package and Choose New View Object name Departments as below


Now we will be creating view object for Department

Uncheck the updatable checkbox.

Select department name and department id.in the order by clause use department ID.
Click next and finish it.Repeat the same step for Employee ViewObject.

Now we will be creating the lov . Double click Departmet view object.
– Select DepartmentId attribute in the attribute page and Click “+” green button at the bottom under List of Values section.

– Click the green + button with List Data Source.
A create List of value wizard will open.In the configuration tab click the + sign if there is no default value is there

On clicking of the ‘+’ sign a view accessor pop up will open.Select Department View Object and shuttle to right side.

In the list attribute select department ID.Click ok.Now your department View object would like as below

Now we will link Lov to the JSPX page.Click new on view controller project.And select jsf page.Give
File name LovPage.In

In the data control palette.Select department view which we created and drag drop on the page

A wizard will open.As you can see department Id is coming as select one choice

Now your jspx page look like this.

Click run on the page. In browser you can see department Id is coming as LOV.It is easy to create.If you want to create lov from another entity object then you need to have accessor on that referring entity object.And you will use that accessor in List Data source in configuration tab.

Insights of ADF logging in ADF Framework

Logging is an important in debugging and tracing the issue.In Adf framework we have ADF logger.
How to use it ADF logger in ADF application.Hopefully , after reading you will have a good idea on it.

Q) How to Turn On Diagnostic Logging

To turn on diagnostic logging, set the Java system property named
jbo.debugoutput to the value console. Additionally, the value ADFLogger lets
you route diagnostics through the standard Logger implementation, which can be
controlled in a standard way through the logging.xml file
Inside JDeveloper is to edit your project properties and in the Run/Debug page, select a run
configuration and click Edit. Then add the string -Djbo.debugoutput=console to
the Java Options field.

Q)How to locate the logging.xml

There are following two ways to get to the logging configuration screen.
1. Open the Application Server Navigator (Ctrl + Shift + G), right mouse click on the IntegratedWeblogicServer and select Configure Oracle Diagnostic Logging for “IntegratedWeblogicServer”.
2. From the Log window (usually docked underneath your editor) pull down the Actions menu and select Configure Oracle diagnostic Logging.

How to configure log level
we need to set the log Level to at least FINE. Let’s set it to the most detailed level FINEST – TRACE:32 or anything you want to set ,if using ODL Log Levels – for the oracle.jbo logger.

If you are using Integrated WebLogic Server in JDeveloper on the Windows platform,
you can find the logging.xml file in a location similar to:
C:\Documents and Settings\username\ApplicationData\JDeveloper\latest_system_folder\DefaultDomain\config\fmwconfig\servers\DefaultServer The log files for Integrated WebLogic Server are in a location similar to:
C:\Documents and Settings\username\ApplicationData\JDeveloper\latest_system_folder\DefaultDomain\servers\DefaultServer\logs

The log files for a standalone WebLogic Server instance are in a location similar to:
$domain_home/servers/your_servername/logs

In the Project Properties dialog, click the Run/Debug/Profile node and create a
new run configuration.. In the Run Configurations list, double-click the new run configuration to edit its
properties.4. In the Edit Run Configuration dialog, for Launch Settings, enter the following
Java options for the default virtual machine:
-Djbo.debugoutput=adflogger -Djbo.adflogger.level=FINE
Set the level=FINE for detailed diagnostic messages
With this the setup is completed. Now open the file (AM, bean or any java class) which belongs to above package and add log messages as shown in below sample file.

LogLevelMapping

You need to set logging in your java classes as below this.

private static final ADFLogger logger= ADFLogger.createADFLogger("Implementation class vinay.class");

createADFLogger() function will create the logger instance .
After initializing the logger, you can use logging within the method as

private static ADFLogger log= ADFLogger.createADFLogger(GammaAMImpl.class);  
For debug messages in try block/ normal debug messages , write  
if(log.isFine()){ log.fine(String classname,String methodname,String message); }  


One important thing ,you need to include the package directory of the implementation project in Logging.xml for adfLogger.

I have used a lot log4j in my jee application.Then why I should use ADF logger compare to log4j.I found view of some adf expert on internet .So sharing with you all. Not sure about all the points:-

Pros to use ADFLogger:

– You can control trace level in Oracle Fusion Middleware Console (Enterprise Manager) with a visual interface.
– You have support by Oracle if you are having problems with logging solution.
– You have an ADFLogger for JavaScript too.
– Have more trace level’s than log4j.

Cons to use ADFLogger:

– You need to associate ADF libraries to your PDK’s.

Pros to use log4j:

– Best known for most developers.
– Easy to set different log strategies and file sizes.
– Goog performance.
– Easy to extend and use Wrappers with it.

Cons to use log4j:

– You can’t control trace level with visual interface provided by Oracle. You need to change manually log4j.properties
– You haven’t Oracle Support for log4j.

It’s only my own opinion. To me is recommended to use ADFLogger if you are in ADF Application. If you are in a JSR-168 or another application use log4j instead of ADFLogger.