Understanding the JSF Immediate Attribute

As, i am working on my project.I have to use cancel button.So somebody said make immediate attribute to true.There is very common myth among ADF and JSF developers that using Immediate attribute will avoid unnecessary validation in any case. It is not 100% correct. Basically , everyone not very much clear about it. If we don’t use correctly , application can work randomly.Let discuss more about it to have better understanding.

In ADF application we have either

1. input component
2. Command component

You can use the immediate attribute to allow components on the page to be validated in the Apply Request Values phase of the life cycle as opposed to the Process Validations phase:

•Input component- Using immediate on an means that that component’s value is validated before any input components that do not have the immediate attribute set to true. Therefore, if a validation error occurs on an immediate input component, the life cycle moves from the Apply Request Values phase (where the immediate attribute is evaluated) to the render phase, and validation does not run on any “nonimmediate” input components. Additionally, if the new value of an immediate input component is different from the existing value, then a ValueChangeEvent is raised. However, instead of the event being processed during the Process Validations phase, the event is processed at the end of the Apply Request Values phase. Therefore, any ValueChangeListener associated with the immediate input component executes before any command component’s ActionListener (assuming the command component occurs later on the page).


• Command Components-
if set to immediate and the component has an action that
returns a value for navigation, the life cycle proceeds directly to the Render Response
phase. The validation and model update phases are skipped. A Cancel button is an example of when this would be used

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.

Remove duplicate entries in a Vector in java

One of the solution which normally every java developer faced once.We have to remove the duplicate
value from a vector in java.

There are two solution for it one.

1.

Vector newVect = new Vector(new LinkedHashSet(originalVect));


or this, if you do not need a new Vector object created

2

Collection noDup = new LinkedHashSet(vectorContainingDup);
vectorContainingDup.clear();
vectorContainingDup.addAll(noDup);

In both cases we puting duplicate vector in linkedHashSet , which will remove the duplicate values.

Enjoy coding 🙂 with techartifact………………………….