Search 800 + Posts

May 5, 2009

How to Create LOV in JSF Page (Java /SOA)

In this blog I will explain in details how to create LOV on JSF Page.
Test case – In this example, I will create a VO on STATEMENT_LINES(BgStatementLinesView). One of attribute of this VO is Budget category_id.I will create another VO on BUDGET_CATEGORY(BgBudgetCategoryView) , this VO has attributes
1.Category ID
2.Category Name.
Finally I create LOV that will display category Name and category ID and attach that to the category_id attribute of BUDGET_LINES.
1.Open Oracle Jdeveloper (Jdev11g).
2.Select New application.
3.Select the template Fusion Web Application (ADF) and Wizard will help you to create TWO projects.
View Controller.
Model is for Data Control and ViewController for UI.In Model Project Design the Business Services by selecting categories > business tier >ADF Business components >“Business Components from table”.
1. Complete Database connection Setup.

2. Select the BUDGET_LINES and BUDGET_CATEGORIES table and created Entity Object (EO). Then Create VO budgetlinesVOI and budgetcategoryVO finally create Application Module (AM)

3. Creation of Application Model will exposed our VO to client, and they will appear under Data Control.

4.Save your Work.

In ViewController Project open adfc-config.xml and drag a JSF page component by dragging View from Component palette. Save your work

1. Open the page and save it as budgetlov.jspx. (Please note that this is unbounded task flow).
2.Drag Statement lines VO (BgStatementLilnesView)from data control and drop on JSF pages as ADF Form.
3.Open BgStatementLilnesView.xml and Select View Accessor and then select ADD (+).
4. Add BudgetCategory VO (bgBudgetCategoryView1) to BudgetStatementLines VO by moving bugetcategory VO from “Available View Objects “ to “View Accessors” as shown in Pic1.1

4. Go to the attributes of the BgStatementLinesView.xml (STATEMENT LINES VO) select the attribute where you want attach LOV (in my case it is CategoryId).

5. Double click the attribute

6. Select List of Values (in Searach) and then Check the check box “Enable List of values”, it will highlight the category view “BgBudgetCategoryView1” , double click the category ID (because we want to build LOV on category ID , as category_id column exists in both the Vos).

7. Go to “Go to UI Hints” tab

8. Set Default List Type = Combo box with List of valies and Include Search region = All Queryable Attributes

9. If Include Search Region = “All Query able attribute” LOV will popup search block which allow us to search based on all the fields of category table

On the other hand , if we have requirement to allow user to query based on few attribute we need to define the view criteria.In my example I have added a restriction to allow user to do query based on 1.BudgetID
by defining view criteria and let’s go back to LOV again.

As we can see in above Pic while defing LOV definition we can see just defined view criteria that we have created in previous step.
Save and Run page again

Seach page on selecting the category ID attribute will allow us to Query only based on BudgetID, BudgetName and Comments.

Litte more Add on for this blog - If we change Default List Type to Choice List , JSF page will not dispaly serach Page any more , It will just list of value with category ID and category Name.

No comments:

Post a Comment