Thursday, February 28, 2013

Using af:Iterator with master/detail to display data in custom layouts


Below example shows steps to use af:iterator in a master/detail senario

1. Create a ADF BC components(EO, VO, AM) with the viewlink for master/detail.

2. Drag and drop the master on to the page as tree table.

3. Create the first iterator to access the master collection via above tree binding, create the second iterator via the accessor binding. (Accessor name is present in the binding defination also in the view link defination)

4. You can create different combination of layout with this approach.



5. You can download the complete example here.

Saturday, February 9, 2013

ADF: Searching with ID while displaying Name in Query Panel

Adding attributes into query panel is simple, just adding them to the view criteria would automatically add the attributes into the query panel. This works for most types of component types i.e inputText, inputDate, chioceList, selectBooleanChoice etc. There is an additional step if you need to add a search attribute of type ListOfValues or ComboListOfValues and use corresponding ID for search.

1. Add a transient attribute into the view Object.


2. Add a view accessor and define the LOV on the  DepartmentName attribute.





3. Define a new view criteria and add the transient attribute DepartmentName and the corresponding Query attribute into the ViewCriteria.



4. Hide the DepartmentId in the query panel. Now when you search for employees using the deparmentName, search query is built using the Id attribute. (This would help the query performance by picking up index defined on the ID attribute if any.)



5. Search by Department Name.



You can download the complete example here.

Sunday, February 3, 2013

ADF: Passing parameter from EL Expression workaround


Below example show a workaround to pass a single parameter from ELexpression into a managed bean.

1. Create a getter method in the managed bean that returns a Map. In this method return an anonymous subclass of hashmap. Override the get method use the parameter passed from the EL expression.



2. Pass the parameter from the EL expression using the box syntax.






3. You can also access bindings to pass a parameter with a similar syntax.


You can download the example here.

Saturday, February 2, 2013

ADF: Auditing Changes to the same Database table. (recording history of changes)


Auditing the changes to a database record can be done in multiple ways. One of the ways is to store the changed record and the original record in the same table. A column would differentiate the active record from the audit record.

This can be easily acheived in ADF BC. Below example demonstrates the steps needed.

1. Data Model.
ACTIVE - indicates the if the record is a current record or a audit row.
ACTIVE_ID - stores the original id

 2. Create ADF BC EO/VO as below. Configure the EntityObject with history columns, primary key genration logic etc.



3. Create a subclass of EntityImpl and override doDML(). The logic below captures Update operation and splits the row into two. The current row contains the updated values and a new row contains the old values. Delete operation is captured and propagated as update operation with setting active flag to "N".



4. Configure the CustAuditEO to use the above base class.

5. Create a View Criteria to filter active records.



6. Create a view link within the same view object, joining on Id and AuditId



7. Expose the View Object Instances in AM Data Model as below. And configure the base view object to show only active records.



8. Run the UI project. Create a new row. save the changes. Update the row and save the changes. Click the view history button to see the complete audit trail of changes.


You can download the example here.

Related Posts Plugin for WordPress, Blogger...