Showing posts from July, 2012

ADF : Call Method from PageDefinition Programatically

I will explain how to call  a method in Managed Bean from PageDefinition using Java code.

1- Create methodAction binding in PageDefinition for a method

You can add  methodAction  binding in PageDefinition for a methods exists in ViewObjects or Application Modules at Data Control

Open PageDefinition and add new action 

Change Look and Feel of oracle Forms

To change look and feel of Oracle Forms open the following file

Forms 11g

Forms 10g %FormsHome%\forms\server\formsweb.cfg

Regarding different version of Oracle Forms 11g you can search about  formsweb.cfg file in MiddleWare Home also. Locate element lookandfeel in any section like the following [sepwin] lookandfeel=Generic [webutil] lookAndFeel=windows
lookandfeel can be one of the following
Note change lookandfeel doesn't require restart service to take effect, It effects directly after saving formsweb.cfg file.


Oracle DB 11g New Feature (Read Only Tables)

I posted before about new features about Oracle Database 11g you can read it from below
Oracle DB 11g New Feature ( Virtual Columns ) Oracle DB 11g New Feature ( Compound Triggers )Today I will produce new feature which called Read Only Tables Read only tables are like normal  tables but it restricts any transaction to perform any DML(Insert, Update, Delete) operation against it.

Before oracle database version 11g READ ONLY was related to DATABASE and TABLE SPACE only but in version 11g you can do READ ONLY to tables too.

ArrayList in Java

My post today is about java.util.ArrayList in java and how to perform popular operation on ArrayList.

When writing this post I find the best thing is to write java class for doing operations  and commenting the operation in class.

import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.ListIterator; public class ArrayListDemo { public static void arrayListOperations() { //Create new two objects of ArrayList System.out.println("==============================================================="); System.out.println("Create new two objects of ArrayList"); ArrayList list1 = new ArrayList(); ArrayList list2 = new ArrayList(); // Adding to list1 object 10 elements using loop System.out.println("==============================================================="); …

Play with NULL Value

NULL is big problem in whole programming language, Today I will write about NULL and  what's the problems we face in code and tips to play with NULL values.

Calling any method or variable of Class has NULL value raise exception in other programming language like C++, Java, C# ,.... etc but in PLSQL it doesn't raise any exception.
If I use NULL in any calculation or logical condition, the output will be NULL.

I wrote before about Three-Valued Logic and the problem  in three-valued logic in PLSQL is NULL value.

Lets see example work with NULL before begin illustration.
If I run previous code it will print
My name is Mahmoud

Create Insert Statement for Table Data

In every site we have more than one environment (Testing, Development, Production, .....etc).
Sometimes we insert any data in one environment and want to migrate it to another environment.

Usually we use database editors to do this task like (Toad, Plsql Developer, SQL developer, .... etc), but in my post today I will create PLSQL function that will generate insert statement for you.

Here is the GEN_INSERT_STATEMENT function is used return SQL select  statement against input table parameter which we can use it to generate insert statement

Custom Exception in ADF

Sometimes in your business logic you want to throw an exception regarding business requirements not Java syntax coding exception.
For example you want to raise an exception that birthday is not later than hire date.

To implement this cased in ADF I prefer the below steps.
1- Create new "ApplicationException" class and extend oracle.jbo.JboException

Create new custom class which extends oracle.jbo.JboException for adding your custom code to exception later.

Search about Text in Schema

I will present today solution help us in searching about specific text in entire schema.

Suppose you want to search about 'MANAGER' string at entire tables in your schema.
You will do select statement against every table in your schema and you will will identify every column in table at select statement.

So I developed generic procedure has input search text and generate select statement against every table in schema and execute it and return the result in DBMS OUTPUT console.

The procedure return ROWD per every table has search text in any of its own columns and print it in DBMS OUTUT console in below format

Add Validation at Runtime in ADF

An user request the below requirement.
He want to change validation condition in specific attribute at Entity Object at runtime.

For example there is a maximum of employee salary which can be changed at runtime, therefore the user doesn't want the maximum salary of employee to be fixed.

So I will create a new method for setting Validation Expression at runtime using Groovy.

public void addExpressionValidator(AttributeDef attributeDef, String groovyExpression, String errorMessage) { //create new ExpressionValidator JboExpressionValidator jboExpressionValidator = new JboExpressionValidator(false, groovyExpression); //Set an error message jboExpressionValidator.setErrorMsgId(errorMessage); //adding the validator to the attribute ((AttributeDefImpl)attributeDef).addValidator(jboExpressionValidator); }

Playing with LOB Data Types

Lobs are the most difficult data type to store and retrieve in oracle database.
In this article, I am going to discuss extensively how to manipulate LOBs in Oracle database. LOBs that are stored in the database itself like BLOB,CLOB,NCLOB. BFILE which is stored outside the database as Operating System files. BFILEs act as a pointer and store the location of the external OS files in database tables.

Center Canvas and Window in Oracle Forms

Today I will present two dynamic procedure for centering canvas or windows in middle center of the screen.

We always want to show canvas at middle center in another canvas and also for window in oracle forms.

So I will produce today two generic procedures for centering canvas/window at middle center of others.

Centering Canvas To implement displaying canvas at middle center of another canvas (Container canvas) I will create procedure has two parameters ( canvas [C1] and container canvas[C2] ) and procedure will change x,y coordination of canvas[C1] at middle center of canvas[C2]


ADF : Iterate ViewObject

In some cases you want to iterate through ViewObject, To do this you have two choice
1- Iterate through ViewObject and change current row in ViewObject
2- Iterate through ViewObject without changing current row

I will present a code snippet  for every one
Assume that you will do this code in ApplicationModuleImpl class