Monday, April 25, 2011

ADF BC : Disabling ADF Security in one shot


When we enable security in ADF application we have to login every time when we run application tester.


Since we are doing frequent testing of application it is not good idea to waste time.

So lets us disable this security in one shot by changing two properties.

As some may be aware that when we create apply security to adf project.

Open adf-config.xml file


Go to source view and set following properties to false in sec : JaasSecurityContext



ADF BC : Dependent LOV in af query


As in previous post we made dependent lov in af form , now let us try this in af query component.

Expand the datacontrol and drop it as query with table component.

If you run the application it will not work.


Since there is no attribute level accessibility in af query component , we need to set the partial trigger sort of stuff at view object level.

Double click state attribute and select dependent on countryid.


Run the application and it will be working like charm.


ADF BC : Dependent LOV in Oracle ADF


We are going to use HR schema and when user select country drop down we will automatically populate corresponding state belonging to that country.

Let us create ADF BC component for Location table and country table.

1. Add on List of value for CountryId Field as here we are going to add country view to CountryId field and it will show us all countries in List.


Select countryId in list attribute


Then go to Hints tab and select country name that will be visible in list down.


Final look for countryId.


Now just run the application tester and we should expect country drop down. We are still not done since we have to create state LOV.


So we are seeing country LOV. next step is to create state lov and dynamically filter it based on country selected.

Create State LOV

Create new State LOV that will be readonly view object with query

select distinct from location


Instead of writing query manually we will use query builder.


Select Location table and expand it and shuttle state column and click ok.


It has automatically generated query for us. If counry is selected then state will change ,so we need to add where clause with bind variable to this State Lov that will accept CountryId for filtering purpose.

Use query builder for state lov.


Final query will look like this.


Remember we have also create bind variable with same name in state lov as below.


Add this lov to stateprovince column of LocationView and set the following.


Look carefully that we have set the bind variable to CountryId attribute of view if user select Country Lov and select country then it will be passed to statelov that will apply this bind variable to filter the state based on country.

Run the application module tester and select the country and you will see automatically state Is filtered.


Now we need to create GUI based on this.

Drag and Drop location view from datacontrol to jspx page.


If we run the jspx ,it will not work.

We have to first set PartialTrigger on StateLov and make it dependent on Country Drop down change.


Also, we have to make countryId autosubmit property to true ,so when it get submitted whole page will not get refreshed and it will dynamically change state lov.

Intially statelov is null ,but when we select country then it will get populated.



Dependent LOV made simple

Wednesday, April 20, 2011

ADF BC : Joins in View Object.


As we are all aware that ADF BC View Object provides us the way to create view object based on joins using various association between Entity Object.

Inner Join – If row exist in both entities

Left outer Join – All row from first entity object are returned no matter row are there in second entity or not.

Right outer Join – All row from second entity object are returned no matter row are there in first entity or not.

Reference Entity :- This is most commonly used to get the information from other entity for display purpose.

Reference entity is displayed in readonly mode.

Monday, April 18, 2011

ADF BC : Read Only Attribute on GUI


This is small thing , but I have seen developer using JSFF readOnly property to set the inputtext or any other GUI element to make it as true.

However ,it is better we do it as ADF BC level.

Double click the attribute that you want to make read only and set updatable to never.


This setting will prevent generation of setter method and attempt to set this will throw ReadOnlyAttrException.

JBO-25013 : TooManyobjectsException


oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key[Key null ].


- If you try to insert duplicate value through ADF BC or trigger then this exception will be thrown.

ADF BC : Refreshing some Cardinality in ADF BC



1 Means each Detail row must corresponds to one master row

* Means each master row can correspond to any number of detail row


“0..1” means each detail row can correspond to 0 or 1 master row.


This is pure one to one cardinality

Most used relationships for better normalized schema are one to one , one to many , many to one and many to many.

Remember that many to many relationship has 3 table , one source , one destination and one intersection table that map between two.

HR Schema has Employee , Job , JobHistory

TableEmployee – EmployeeId

JobHistory – EmployeeId , JobId

TableJob – Jobid

ADF BC : Property Sets in Business Component


As we know that we use ADF BC Control hints to set the properties like title , tooltips for attribute.

However ,if we have same attribute used in every business component wouldn’t it be better if we create property set for that attribute.

Advantage :-

If we set control hints for attribute then


It modifies two files with following property.

BC.xml file will contain property tag that will reference the property in file.

image file contain following values.


So actually there are lot of entries created for just two properties file.

Let’s assume you have same property in some 500 view object ,so you end up with 1000 entries for it.

Reading from text file will have performance issue and hashmap will take lot of heap size of JVM too.

Property Set

Let us create a property set for this and let example give the advantage in it.


name property set as SalarSet.

Add two properties as below.


Look at the source. Here property set is referring to resource bundle , but it will be one time reference.


Got to BC object and set the property set for following attribute.


We can set the property set for all salary field in all objects in our project.

Best idea will be to create property set in common project ,so it can be used as library every where.

If you look at source again for attribute then we will have domain reference


Remember to delete property reference after having this domain.

Enjoy Reusability !!!

ADF BC : Entity Object Must have at least one attribute as primary key


Funny post , but most important thing to do.

When we create Entity Object and database as no primary key then BC generator will create default primary key RowId that can be delete later on when we have any attribute as primary key

Sunday, April 17, 2011

ADF BC : Various way of setting Sequence Number


It is advisable to use sequence number for each ADF BC Entity object and there need to be corresponding sequence number created for each database table in DB.

It is known as ‘Surrogate Key’ or ‘Primary Key’ of ADF BC.

There are various way of populating this key for ADF BC component and I am trying to give few of best practices.

1. Using Create() method of entity

There is create method in BC Entity Object that can be overidden to assign primary key. Go to java tab for ADF BC entity object and generate this java class and don’t forget to select Create Method check box.


After that go to and search for create method and write the following statement of SequenceImpl


Disadvantage of this way is ,if transaction is rollback then sequence number is lost.

2.  Using DB Trigger

we can use DB trigger to assign the sequence to departmentid and the advantage of this usage is we will retain the sequence number even after transaction is rollback.

Go to department Entity object and set the department id to DbSequence.

Set Updatable to Never since we will not allow user to edit this value

Set refresh after to update because when we use trigger and create row ADF BC will automatically assign negative value to Department id and when we press commit then only it will run trigger and assign value to dept id.

That is why we will not loose sequence number when we do rollback.


Create Trigger using Declarative way

Create a trigger for Department id sequence , there is no need to write trigger ,it can be automatically created by jdeveloper.


Select the following


then select the sql tab and you will see that jdeveloper has automatically created trigger definition for you.



Now run appmodule and create department row and we will see that negative value is assigned to department id.


When we press commit it will generate department id and if we press rollback nothing happens and negative value is rollback instead of sequence number.

3. Using Groovy to generate sequence number.

Here we can write custom method in in custom entity impl class that will be implemented by

don’t forget to select the expression.


adf.object.customMethodName(“SEQ_NAME”) – This method will call generic custom method name that will return the sequence number.


customMethodName definition will be same as point number one except it prototype will be

customMethodName(String SeqNumber){

//call step one code and return sequence number.


4. Fourth way is most easiest and no code required.

(new oracle.jbo.server.SequenceImpl("HR.DEPT_SEQ",adf.object.getDBTransaction())).getSequenceNumber()


Enjoy Primary Key !!!

Thursday, April 14, 2011

Jdeveloper ADF Model Database Documentation

If any one has not noticed there is very nice feature on jdeveloper to see all the schema information in internet explorer like website.

I love this feature so much because it allows me to quickly see all DB object in explorer.

Right click the DB Connection

Click Generate DB Doc


In next dialog we can select what DB object ,however we can select all.



After generating we can access table , views and all db object like website.

Wednesday, April 6, 2011

Jdeveloper–Create EAR project based on multiple ADF Lib Jar.


As we have noticed in previous blog to create one main project and two project that will act as dependent project for main project using adf library.

Now we will have to create EAR file for main project to deploy on applicaton server.

Click Application –> Application properties and go to Deployment.

We will see that jdeveloper has already provided us EAR file for main application.


We can create new EAR or change the properties for existing ear. I would prefer new ear to not hurt jdeveloper default ear for future reference.

For this blog let us click edit on jdeveloper default EAR to look at the various properties.


Frankly speaking by default jdeveloper has provided most of option for ear.

However we can make compression on to reduce the size of generated ear and then we will see what is inside ear.

After deploying to ear , click the ear file.


Jdeveloper has directory exploding feature so no need of any other tool.


click the war file which will contain the two dependent child jar file.


Now we can use this EAR to manually deploy it on weblogic server or use jdeveloper deploy facility using

Application –> deploy


Click next by selecting app server on which we want to deploy application and select stand alone.


We can deploy on single sever or multiple server.


Also , we have not included the manifest and compressed the ear file.

Click Finish.


It will deploy this file on weblogic server.

Verify the deployment

We will notice that it is deployed on weblogic as enterprise application.

Also we can see the context by expanding the + sign.


Test the Page

Click the context ,it will take to weblogic below page , click testing here.


Expand the context name to get the url.

For me it was showing till here ,so I added /faces/mypagename.jspx to test the page.


Test page.


It works !!!!