Wednesday, August 31, 2011

Webcenter : Creating Portal Application and Integration with ADF

 

I will demonstrate how to create web center portal application and consume ADF Task flows based on ADF BC component.

1. Create New WC Portal  Application

image

2. I am selecting default provided by portal.

image

3.You will see default portal structure is created with three data control.

image

Above project structure has following component

- Portal

site navigation , page hierarchies , administration , security , page templates , skins and more.

-PortalWebAssests

This folder is specially for static resources.

Run Home.jspx and you will see following default out of box login page.

image

login as weblogic/weblogic1

image

On top right corner there is “Administration” link which will take you to runtime webcenter navigation customization , create page and much more.

image

In next few blogs we will create our own portal components and new ADF Project to integrate it to portal project.

Webcenter Warning :- Make Sure Your Domain Directory ?

 

When we create webcenter domain make sure it do not contains any spaces in between.

Also , make sure domain is present in folder which do not have spaces in between.

Consequences :- if you have above two point satisfied in your webcenter installation and configuration then pages in webcenter application will not be rendered.

Webcenter : How to verify that you have Webcenter Extension Installed

 

Open Jdeveloper

Help –> About (Click Extensions) and sort by Identifier two times.

You will see version of each component of webcenter like Oracle Composer , Webcenter Rss Services etc.

image

Tuesday, August 30, 2011

Weblogic : Taskflow do not show latest changes after running

 

When you add execute with parameter or new view to task flow run the project then some time I have seen that new taskflow changes are not reflected in running application.

Then you will do following things without any success

- Restart Integrated Weblogic Server

- Restart Jdeveloper

- Clean Project

However , still Task Flow changes are Old.

So what do I do next.

For web Logic there is domain and you can see current running domain by looking in to your J-developer log window.

image

So go to System directory Directory

C:\******\system11.1.1.4.37.59.23

Delete Project inside DRS folder

C:\**\system11.1.1.4.37.59.23\o.j2ee\drs

Result :- when you run project again you will see latest changes of your taskflow.

Delete Project inside ADRS folder

C:\***\system11.1.1.4.37.59.23\o.mds.dt\adrs

This will delete some mds stuff.

Tuesday, August 23, 2011

Weblogic : Identifying Class Conflict and ClassLoading in deployed ADF Application using CAT Tool in Weblogic

 

List of Class Loader in Weblogic

System Class Loader - Weblogic Classes in weblogic system directory

Domain Class Loader - Domain Classes in domain directory

Application Class Loader - Library from Weblogic-application.xml , APP-INF/lib

WEB APP Class loader - Library from weblogic.xml , WEB-INF/lib , WEB-INF/classes

JSP class loader

Class Conflict

Until Weblogic 10.3.4 there was no tool available in weblogic  to identify class conflict. However , Now weblogic has a tool called CAT (Classloader Analysis Tool) to perform class conflict check.

Let us say you have class call ClassLoadingExample.class in your Ear Application $CLASSPATH.

Also, you have same class in $CLASSPATH of weblogic.

So when you run the application then Weblogic class will be considered ,not the EAR one giving you surprising result.

Filtering Class Loader

This provide us option to configure our deployment description to make sure that our WAR/EAR class are loaded ,not the one in weblogic.

FilteringClassLoader sits between Application and System Class loader. It is child of System Class Loader and Parent of Applicatino Class Loader.

FilteringClassLoader intercept loadClass method and compare className with list of package specified in weblogic-application.xml file. If package matches class name , FilteringClassLoader throws ClassNotFoundException. This exception notifies applicatino classloader to load class from application.

Configure Filtering Class Loader

Add prefer-application-packages description in weblogic-applicatino.xml which detail is of package to be loaded from application.

<prefer-application-packages>  
<package-name>thirdparty package in your application which may be in weblogic</package-name>
</prefer-application-packages>

Installing CAT


CAT is a Web-based class analysis tool provided by weblogic and we need to deploy wls-cat.war which is located in “WL_HOME/server/lib/wls-cat.war”


After deploying it can be accessed in.


http://weblogichost:port/wls-cat/


CAT Display all currently running applications and modules.


You can use this tool to check Classloading conflicts , Check system and application classloaders and even generate report. For further information please refer to oracle documentation.


For me wls-cat.war is located in


image


I login to weblogic console


http://localhost:7101/console


image


Install war as application , not as lib.


image


Finally deployed with following context


image


Go to testing and access the application.


image


CAT TOOL GUI


image


We can use this “Analyze Conflict” , Generate Report etc.


image








Click analyze conflict. It showed me conflicting classes and gave me suggested solution that I can use in my weblogic-application.xml or weblogic.xml.


image

Monday, August 22, 2011

ADF BC : Making specific row read only for critical records.

 

As I have already shown you in previous blog how to make salary column read only based on role condition.

Now let me write a logic to make specific row read only based on it importance.

Generate Impl class for Employee Entity Object.

Override isAttributeUpdateable method.

image

I checked if job is Vice President then do not allow user to edit record.

Run the page and you will see that row with JobId AD_VP is read only.

image

If you notice this time I wrote logic in EntityImpl.java instead of VORowImpl.java. Actually , we can override isAttributeUpdateable method in both Impl. Please refer to documentation for further reference.

ADF BC : How to make whole view object read Only

 

Some time small things make difference and needle can do the job where sword cannot.

There are some system information that need to be read only on GUI and if you have generated VO based on EO then go to following screen and set the updatable flag to false.

image

ADF BC : Make Table , Form ReadOnly based on condition.

 

Let’s say you have requirement ,if one person login he can update the field and other person login he cannot update the field based on role of person.

Let us use standard HR schema.

Scenario 1: If HR Login he can see the salary of employee.

Scenario 2:- if Accountant login he can update the salary to give raise.

1. Create ADF BC EO/VO for Employee table.

2.Create a page jspx and drop it on adfc-config.xml

3.Go to datacontrol and drop EmployeeView to page.

4.Run the page and every field will be editable by default since we have not provided any logic yet.

Now let us generate EmployeeRowImpl.java file since we will be dealing with attribute and single row at a time.

When we generate ROWImpl file for employee view object , we will see each attribute has given index.

image

So when this VO is rendering we can perform some business logic on interested attribute of Salary and make it readonly and editable.

isAttributeUpdateable(int i)

Please override this method on RowImpl.java , you can refer to oracle documentation for further explanation.

I wrote the following code for test before making it to final version based on role for testing.

image

As you can notice I have just compared attribute and if it is salary then make it read only and rest editable.

Run App Tester.

Woow , when I run app tester I can see only Salary is read only for each row.

image

Now let me run simple page with just Employee Table displayed with all records and see if this logic is making all salary disabled.

Wooow , here we go and our salary is read only now.

image

Now our next step is to secure this page and create two role HRRole and ActRole.

Two user each belonging to one role.

Configure Security

After going to Application –> Configure security , I configured security in ADF app.

Create two enterprise role.

image

Create two app role

image

Assigned enterprise role to app role.

image

image

Create two user and assign proper app role.

hr – ActAppRole

act – HrAppRole

image

Real Logic

When HR login we should make salary field read-only and if act login we should make it updatable.

Go back to RowImpl and write following line of code to verify user in roles.

Run app module tester.

image

If user belong to Hr role then make salary as read only ,otherwise editable.

Give permission to page before running jspx.

image

Let us run jspx now and login at HR and ACT and we will see that Salary column is read only for HR and editable for Act user.

image

Wednesday, August 17, 2011

ADF BC : DeleteParticipant Flag do not allow commit after delete.

 

I created ADF BC VO based on EO and set the updatable flag to true ,so that It will allow me to perform DML operation on database table.

image

So when you run the app module tester , you can do create , delete , update and commit,rollback the record.

So when I pressed delete button ,it deleted the row from VO and enabled the commit button to commit changes to DB.

image

Business Requirement Change.

Now our business requirement has changed and we should not allow DML operation on VO. So I just unchecked the updatable flag for VO as below.

image

Now if I run app module tester all record are only read only.

image

When I look at the source of VO.xml following properties were set to prevent DML operation.

image

ReadOnly=true” and DeleteParticipant="false"

Business Requirement Changed again

Now again our business told that we need to have this VO updatable , so I just checked the updatable flag to checked.

I was happy and excited that they can now perform all DML operation again.

NOOOOOO !!! , I was Wrong.

Let me explain what happened.

I checked the updatable flag again , it removed readonly=”true” property , but it did not removed DeleteParticipant=”false” property.

image

Now let us see the impact of this property by running application module tester.

When I ran app module tester , it allowed me “Insert” , “Update” operation and it enabled commit button when I performed this operation.

image

Problem

When I deleted the record ,it deleted record from VO , but did not enabled commit and rollback button.

OOOOPPPSSS !! , What went wrong. After spending some couple of hours on this I finally figured out that when you do Uncheck and Check on updatable flag ,it do no remove DeleteParticipant=”false” property.

Is this Bug ?

I don’t know

Make Sure

Make sure when you do such kind of things make sure this flag is removed manually and make sure to retest your flow again.

Hope other ADF developer will not waste his precious time in figuring our this issue that is whole purpose of my blog Helping and Growing.

Wednesday, August 10, 2011

ADF BC : How to know Database Name Runtime in ADF

 

There are requirement where you want to know which database you are connected at particular instance.

1. Write a method call getConnectionDb() in application module.

image

You can use this for various logging related or for any purpose.