Skip to main content

Posts

Manually refresh a row in a table after data manipulation

It's very common that the requirement asks to handle data manipulation for a ADF table. The data manipulation could be update, create or delete the table row and change some of the attributes in a table row. User interface experience should be achieve as that once the action button/link for the data manipulation has been pressed, the changed data should be reflected right away. It's not acceptable that the user has to refresh the page or search table to render the updated data. Solution to this concern is easier to be fulfilled via declarative handling in Jdeveloper 11g. Setup the "refresh", "refresh condition" of the iterator that the table binds should be considered first to utilize the "PPR" feature of the ADF. But sometimes the declarative handling does not behave as expected, and you need to achieve this manually as a workaround. Here is how I achieve this. Assume we have a manged bean to handle the data manipulation codes. After we select...

Manually Assign new value to sequence column

Sometime we need to manully assign a new value to a sequence column. For example, we have a department table with primary key column department_id, which is based on a sequence "department_sequence". When we try to create a new record in the department table, we will do the following in the AMImpl.java: ************************************************************* DepartmentVOImpl vo = getDepartmentVOImpl(); vo.clearCache(); Row row = vo.createRow(); SequenceImpl sequence = new SequenceImpl("department_sequence, getDBTransaction()); Number dept_id = sequence.getSequenceNumber(); row.setAttribute("DepartmentId", dept_id); //set other attribute values... vo.insertRow(row); getDBTransaction().commit(); *************************************************************

Post Ordering Issue

I have a previous post  about the post ordering constraints error. The situation in that post might be somewhat special: the association between two entity objects (master and detail) is a DBSequence in the master table. Here is a working solution to the generic post ordering issue. Steve Muench has an article " Forcing a New Dept to Post Before a New Emp Without Composition ", which presented two ways to solve the post ordering contraints: 1. Override postChanges() method in the detail/child entity object Implementation java file. For example, if Dept and Emp table, then write below codes in EmpImpl.java file: 2. An even simpler way: Steve also has a very good article on " Most Commonly Used Methods in ADF Business Components " which lists all common used methods in EO, VO, AM, etc.

Setup SSL Certificate for PayFlow Gateway in Weblogic 10.3

PayFlow Pro is a gateway provided by PayPal Inc for payment transactions, like credit card transaction. To use payFlow gateway in ADF application, you have to install the payFlow SDK from Paypal. You can find info in here . After installation of payFlow processor you can download the payflow Java Library and write codes to process the transaction. But before that, you have to set up the SSL on your server to make it work. The SSL is installed on your development server to recognize the PayFlow's transaction process server, therefore the SSL has to be installed into the trust keystore on the weblogic server. For test and development purpose, the SSL certificate can just added to the default existing keystore in Weblogic server. The steps are here: 1. download the SSL certificate that can recognize PayFlow server. It can be downloaded from either A or C link.The download link is here . 2. Use keytool command to import the certificate into the existing trust keystore for dev...

Implement Cascading lists of values in ADF 11g

In many cases, we will have to use cascading lists of values, also called dependent lists of values in our ADF application. Cascading lists of values, in its name, means one set of list of values are dependent on selected value on  another set of list of values. How does it work is apply view criteria to a model driven list of value . Here I present one example in HR schema. Let's say we have a list of departments, when one department value is selected, a second list of values - manager will be set to managers within the selected departments, a third list of values - employees will be set to employees under the selected manager. First, we create our base VO - EmployeesVO (can be created from Entity object also) Second, we create 3 list of values for 3 attributes we are interested in EmployeesVO: DepartmentId, ManagerId, EmployeeId. Each list of value needs a view accessor (data source for the LOV).  DepartmentId attribute needs a view accessor from DeptListVO, wh...

Build Custom Search in ADF 11g

Although ADF 11g provides us with declarative search component for a search functionality, in many cases it still cannot satisfy the business requirements. Here I am presenting a way to build a custom search page without using build-in search component in ADF 11g. This example was built under HR schema to search employees using tables: employees, departments, jobs, locations, countries. Normally, we will catch the user input in managed beans and send the user input back to our model, and explicitly run the executeQuery() against the iterator that binds to the results table. here I did something differently.... I am using another VO with transient attributes to catch the search criteria user inputs, and send these inputs into the VO iterator which binds the search results table. So when user inputs search criteria, the changes will retain in a VO Row and I will user getter method to catch the changes and send the changes to the VO that I can run executeQuery() to do the search. To ...

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;"); ...