Saturday, May 31, 2014

Installing ADF Faces Components Demo

In this post the we’ll walk through the steps for downloading ADF Faces Components Demo in Jdeveloper environment. I am using Jdeveloper version 11.1.1.6.
You need OTN account (free account) for downloading the WAR file.
Access the downloadable WAR file (rcf-dvt-demo.war) from OTN which can be accessed here.
This is a WAR file containing a comprehensive demo of all the components as well as various framework features. The WAR file contains the source code for the demo.


The rich client component runtime demo can be started from inside Oracle JDeveloper 11 using the integrated Oracle Weblogic Server.
Create a directory under C:\Jdeveloper\mywork directory. This is the directory where Jdeveloper create/stores all applications by default.
Depending on file associations in your browser on your PC, this file may download as ZIP file. Just rename the file to .war extension from .zip.

Start Oracle JDeveloper and choose File | New from the menu. Select Applications and press Ok.
In the Create Application dialog type adffacesdemo as the application name and press Finish.

This creates new application workspace and project. The project is not needed and you may delete the project, choosing File | Delete Project file from disk in the Oracle JDeveloper 11g menu.
Choose File | New from the JDeveloper menu and select Projects.
In the list of items, select Project from WAR File and press Ok.

Skip the first dialog panel, and provide a name for the project, e.g. adffacesdemo, on the second.
Keep the Directory information .
On the third panel, use the file browser to select the ADF Faces demo WAR file on your file system and finish the wizard.
This step will take 1 or 2 minutes…
Save the application.
Double click onto the project node to open the project properties and select the Run | Debug | Profile option.
Press the Edit button and select the Tool Settings. In the Before Running section, uncheck the Make Project option and close the dialog pressing Ok.
Expand the project and select index.jspx under the Web Content node and Choose Run from the right mouse context menu.
The Face DVT Demo application will open up in your default browser.

Good Luck.

Assigning primary key value using Oracle Sequence

Many applications define tables with primary key which is populated using values from database sequence. There are several posts on the net that describe these techniques with some links listed below as references. In ADF applications there are several approaches to implement assignment of primary key values.
1. Using Groovy Expression in Entity class.
2. Overriding the create method of the Entity class.
3. Using database trigger.

1. Assign Primary Key values using ADF Entity level using Groovy Expression
SequenceImpl class is used in groovy expression of the key attribute of the entity. getSequenceNumber() method of the SequenceImpl class can be invoked using the database sequence.
In the Entity or the updatable View Object editor the following expression can be set in the properties of the key attribute as shown below.

(new oracle.jbo.server.SequenceImpl("T1_SEQ",object.getDBTransaction())).getSequenceNumber()


Save the application and to test run the application module. Let us add a new row and notice that next sequence value is retrieved.


1. Assign Primary Key values by overriding create method of the entity class
To override the create method of the entity class, generate  the java Accessors  (source code)  as shown below.


Once the java class is created modify the create method with following code.

    @Override
    protected void create(AttributeList attributeList) {
        super.create(attributeList);
        SequenceImpl seq = new SequenceImpl("T2_SEQ", getDBTransaction());
        Integer seqNextval;
        seqNextval = seq.getSequenceNumber().intValue();
        setT2Id(seqNextval);
    }

Save the application and to test run the application module. Let us add a new row and notice that next sequence value is retrieved.


3. Assign Primary Key values by using database trigger
Use the database navigator to access the table, right-click on the table and select Create (PK from Sequence…) option.



Once a trigger is created, change the attribute type of the primary key column in the entity class to DBSequence.



Save the application and to test run the application module. Let us add a new row and notice that next sequence value is retrieved.
Note that a negative value is assigned until the actual INSERT is executed on the table in the database, which fires the trigger to assign new sequence value. This negative value is used to manage the entity relationships in the framework until changes are saved to the database. Once the changes are saved the framework will refresh the trigger assigned key value.


Till Next post  Bye.

Reference:

SQL Developer 4.0 - "Streams has already been closed"!

This error in SQL Developer (4.0) appears when you execute an SQL in SQL Worksheet with some errors. Any further execution of the SQL results in same error.

Once you correct the SQL and rerun the SQL you get the same error…


Any further execution of the SQL gives the same error. However if you “refresh” the result set SQL developer re-executes the SQL properly and returns he result.


SQL developer 4.0 has lots of new functionality and performance better.

Happy exploring…