Tuesday, April 6, 2010

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);
}
4. This step is to handle the UI part. There are many options, but here I am using a bounded task flow for the user registration process.
(1). create a bounded task flow, and drag the simpleRegistrationCreate method from dataModel to the blank bounded task flow and the method automatically set as the default activity in the task flow.
(2). create a fragment named as Registration.jsff, drag the VO from dataModel into the page fragment and select/deselect the data column you need the user to fill.
(3). drag "Commit" from DataModel to the task flow as a method activity. create another fragment as the registration confirmation if you need to.
(4). now connect the activities using control flows (navigation flows).
(5) drag the task flow into a page as a static/dynamic region for the user to register.

No comments: