ADF Specialists Blog
Saturday, March 2, 2013
Customizing the Columns of a Pivot Table
1. Add the pviot table to the page.
2. Add varStatus and var attributes to dvt:pivotTable. Add dvt:dataCell, a switcher and configure as below
3. You can add a button, link etc.
4. Download the complete example here.
Note: If you are using export, the switcher component does not work. Add rendered property ( rendered="#{cellStatus.cellIndex.column==0} ) to control the values exported.
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.
1. Add a transient attribute into the view Object.
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.
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
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.
Sunday, January 6, 2013
ADF: Default Detail, Only One Detail Row can have the default flag set
1. Create ADF BC components and setup the AM Datamodel for master detail. From the data control panel drop the detail as Master Form and Detail Table.
2.
Drop the Preferred Flas as a Single Selection
Column, Boolean Checkbox on the detail table. Choose the selected and
unselected values for the checkbox.
3.
Edit the properties of the Checkbox, add auto
submit to true and set partial trigger on the detail table to the checkbox. Add
a value change listener and bind it to a bean proeperty.
4.
Add logic in value change listener to update all
other rows when a new default row is selected.
5.
Run the application and select a new default
row, you can observe that the other default row already selected is cleared.
You can download the complete application here.
ADF: Simple steps create a Shared Application Module instance to improve performance
Below steps show how to create define a Application Module
instance and share it across application.
1.
Build ADF BC for HR tables Employees,
Departments. Create two application Modules EmployeeAM and CommonAM.
2.
Add Departments View Object instance in CommonAM
Data Model.
3.
Add Employees View Object instance in EmployeeAM
Data Model.
4.
Go to Model project properties -> Business
Components -> Application Module instances. Here you’ll see option to add an
Application Module instance as shared across Application or Session.
5.
Now you’ll be able to see the Shared Application
Module Instance when declaring view accessors for a view object.
6.
If you create two different connection pools for
each AM, and assign them accordingly in AM configurations.
7.
Open two separate page in two different browsers
you can observe that the Shared Application Module uses a single database
connection.
8.
Using this option provides following performance
benefits
·
Improved runtime performance.
·
Numbers of queries executed against database are
reduced.
·
Memory utilization for storing view object rows
is reduced.
Subscribe to:
Posts (Atom)