Tuesday, February 11, 2014

LOV (List of Values) using EJBs

Following a request, I would like in this post to demonstrate how to use EJBs to build your business services and how to build a simple form with a list-of-value component (using the selectOneChoice component).

 I created an application using the "Fusion Web Application (ADF)" template, i initialized my model project by creating a database connection to the HR schema and created two EJB entities, one for the Employees table and one for the Departments table.


I created a session bean using the default settings (with all methods from both entities being selected) and generated a data control from the session bean by just right-clicking on the session bean and selecting from the context menu "Create Data Control".


I created a page (employees.jspx) and dropped the employeesFindAll collection on the page as a form (for demo purposes i am just using three attributes: EmployeeId, FirstName and LastName). The initial requirement was instead of displaying the department id to have a drop down displaying the department name.

When you created the EJB entities from table, ADF interrogated the database catalog and identified the relationship between the two tables, thus injecting it into the Employees EJB.


To add the department name as a list-of-value just drag and drop onto your page the nested departments collection as an ADF Select One Choice component.

Run the employees page and you will see that ADF will synchronize the department list as you navigate between different employees.


Download sample application: LOVsUsingEJBs

No comments:

Post a Comment