In Oracle ADF you can create JSF pages which includes page fragments (A page fragment is a JSF JSP document (file extension is .jsff) that renders as content in another JSF page).
The purpose of page fragments is nothing but re-usability. You can use the same page fragments on different pages with the help of bounded task-flows. The pages with fragment could appears as Regions (fixed visibility) on JSF page you can also create pages with Dynamic Regions (Dynamically visibility on run-time based on some action or condition).
In this example i will create 2 Bounded task flows called "dept-flow" and "emp-flow" with page fragments respectively and later i will display both fragments on a single page as simple Regions.
The result would be like this
Note: Few of the following steps are not important to create pages with Regions but would helpful to understand the concept with examples specially for people coming from 4GL background.
I assumed that you have already setups the project with Hr Connection, employees, departments EOs with default VOs and AM (if you new to ADF please check the my older posts)
Creating Bounded Task flows and Page Fragments:
- First step is to create bounded task-flow. Right click Choose New on ViewController Project and select ADF Task Flow in Web Tier > JSF category
- Named it as "dept-flow" as shown in the slide make sure Create as Bounded Task Flow and Create with Page Fragments already selected.
- Drop a View activity named it as "dept" on the Task flow double click it and create a page with fragments.
Note: Change the directory at the end as public_html\fragments to keep your fragments separate
- Create the dept page as shown in the slide by dropping a vertical panel splitter and ADF read-only table at the first facet and ADF form in the second facet both from DepartmentsView DataControls iterators (as shown in the slide)
- Set the Partial trigger property of the Form panel layout component so it will change its data according to the af:table for DepartmentsView
- Repeat the all above steps for emp-flow by creating new bounded Task flow
- Create emp page based on Single strech column apply a theme to it
- Drop simple EmployeeView Iterator from Data control to the new Page fragment as ADF Read-only Table.
Now you are complete with your page fragments time to move on to next step
Creating JSF page to display Page Fragments
- Right click choose new on ViewController Project choose JSF page
- Choose Template as 3 Column Template
- The page would appear like this
- Drag and Drop the dept-flow from Application Navigator to the end facet of the new page a menu will appear choose Create > Region as shown in the slide
- Repeat the same step and drop the emp-flow to the center facet
- Create a AdfOutputText in the start facet and set value to "Page Fragments Example" your page at design time would looks like this
Note that our both regions are not editable on this page if you want to do any changes go to actual page fragment and change it.
- Right click and choose Run you will see the following page on run-time.
As you have seen with Oracle ADF Web development becoming easy and fun. ADF Task flow is powerful feature of Oracle ADF which provides a great usability and provides a modular approach defining control flow in the application and Page fragments gave us re-usability.
You can Download the working example