Skip to main content

Posts

Avoid using DBSequence as the foriegn key in master-details relationship

The reason of why to avoid using DBSequence as the foreign key in the Master-details relationship when you need to post the data into the database. A user case for this scenario: you have two tables: User and UserGrant tables. User table has columns related to user info: user_id, user_name, user_password, user_address, etc. UserGrant has columns related to user and group info: grant_id, role_id, user_id, etc. User is the master table and has the primary key user_Id as a DBSequence. The user_id is also a foreign key in UserGrant table. You create VO based on the entities that based on the two tables, and drag the UserVO to the ADF page to create a new row. When a new role (which means a new user) created in UserEO, you want a new role (which means a new grant: a new user with a role) to be created the same time in UserGrantEO. The issue rises because the posting order of the two entity objects. This is because when a new role is created (before posting data and commit), the DBSequence...

Create Data in ADF

Suppose you have to handle a process of user registration in ADF fusion application. Then you will have the page for user to put their user info (user name, user password, and other personal info) into your database. So to implement the process of create data in ADF, you need to do the following: 1. create entity objects for the database tables. 2. create view objects for the data objects that will be handled with user interaction. 3. expose the VO to AM and we need to write some custom codes in AMImpl java file we will use later. The method is about to create a new row in the VO. Expose this method after creation. For example: public void simpleRegistrationCreate(String userType, Number assignedBy, String userRole) { ViewObject userVO = this.getWebUserVO(); Row currRow = userVO.createRow(); currRow.setAttribute("UserType", userType); currRow.setAttribute("AssignedBy", assignedBy); currRow.setAttribute("UserRole", userRole); userVO.insertRow(currRow)...

ADF Business Validation: password have to match confirm password.

There are many business validations we need to handle in ADF. Most of them are done at the attribute level. But one of them: password/email have to match confirm password/email scenoria has to be done via entity level. This can also be done not using the business level validation instead by using UI handling. Here is code example:

Create or CreateInsert

Taken from Jdeveloper 11g handbook: Create or CreateInsert? The two different create operations provided by ADF, Create and CreateInsert, can be a little confusing because they seem to accomplish the same task. The row created by the Create operation is managed as a temporary object by the framework. If the user abandons an input screen without submitting the new record, the row will simply disappear, leaving the programmer with no clean-up to do. CreateInsert, however, requires clean-up. Although the Create behavior is generally more useful, there are still some circumstances where CreateInsert should be used. Typically, this will be when the side effects of entity object creation are desirable. For example, the create method on the entity object adds information defined as defaults for attributes such as dates and reference numbers. With CreateInsert, this default information will be visible to the user on the created (blank) record. If the Create operation is used, the ...

Dynamic Tab Functionality

I followed a recent blog from Andrejus Baranovskis on a Dynamic Tab Functionality . Actually this functionality is very similar to Dynamic Region Functionality. An example of dynamic region can be found here . To summarize how to implement dynamic region functionality: 1. create several bounded task flows that you wish to be a member of the dynamic region. 2. drag the task flow you wish to be displayed by default into the region on a JSF page, and choose "dynamic region" tag, you will be asked to set a bean to handle the regions switch. 3. drag the other task flow to the region you want to control the region switch (like the navigation panel), and choose "dynamic link" and choose the dynamic region you created in step 2 (the name is "dynamicRegion1" by default). Jdeveloper will create the codes in the bean to handle the region switch when you hit any of the command links you created in this step. For Dynamic Tab Functionality, the steps are: 1....

Bounded task flow in ADF Regions

ADF bounded flows that execute in ADF regions are key enablers of enterprise web 2.0 development with the Oracle Fusion development platform. Bounded task flows let you build desktop-like web user interfaces that unveil the real power of Asynchronous JavaScript and XML (AJAX) without exposing developers to the complexity of AJAX programming. How to Access the task flow binding from Java: BindingContext bctx = BindingContext.getCurrent(); BindingContainer bindings = bctx.getCurrentBindingEntry(); DCTaskFlowBinding taskFlowBinding = null; taskFlowBinding = (DCTaskFlowBinding)bindings.get("dynamicRegion1"); The task flow binding is accessed by its name, "dyanamicRegion1", in this example.

User Database Tables to implement authentication in ADF

It is always a common requirement for a developer to use the database to store user authentication info, such as user name, password, user role, etc. User authentication database provider is available both in iAS 10g and Weblogic 11g, but it's different in their implementations. In Oracle Application server 10g, the security guide is well documented on how to setup and use the custom login module to implement security using database tables as the source provider. Frank has well documented the steps here . Several good blogs have also noted on this ( link 1 , link 2 ). The custom login module DBTableOraDataSourceLoginModule is avaiable in OC4J 10g. As in Weblogic 11g, the login module is not available directly but instead another provider called SQL Authenticator takes the role. Edwin Biemond has documented an working example on setup SQL authenticator in 11g: Using database tables as authentication provider in WebLogic   and Using a WebLogic provider as authentication for ADF S...

Debug OAF-7 ways

1. Use System.out.println When running the OA Framework pages from jDeveloper itself, you can write debug messages using System.out.println. These debug messages will be displayed in the console of jDeveloper. Pro * Ease of use, as you simply enter free text messages * Debug messages simply appear without the need to set any profile optionsCons * Too much typing, which can be avoided when using the debugger of jDeveloper. * You can debug only those pieces of code that you suspect are causing the error. Unlike to this approach, using jDeveloper debugging, breakpoints can be set for exceptions/classes as well. 2. Use jDeveloper inbuilt Debugger This happens to be my favourite mechanism to debug OA Framework Pages, for the following reasons Pro * To get started just one breakpoint is required, as more and more breakpoints can be added in runtime itself. * You can set generic breakpoints, for example, you can set breakpoint on exceptions, w...

Call PLSQL in OAF

Calling PL/SQL Functions and Procedures Even when writing Java entity objects, you might need to call PL/SQL functions or procedures. Note: Do not use JDBC to perform simple SQL statements. Always leverage view objects for this purpose. If possible, you should define the view object declaratively. In general, to invoke a stored procedure from within an entity object or an application module, you need to: Create a JDBC CallableStatement with the PL/SQL block containing the stored procedure invocation Bind any variables. Execute the statement. Optionally retrieve the values of any OUT parameters. Close the statement. The following application module example shows how to create and use a CallableStatement in an entity object. import java.sql.CallableStatement; import java.sql.SQLException; import java.sql.Types; ... OADBTransaction txn = getDBTransaction(); CallableStatement cs = txn.createCallableStatement("begin dbms_application_info.set_module(:1, :2); end;"); ...