Sunday, December 12, 2010

JSF Page Template for JSF Page Fragment In Oracle ADF 11g

Long time ago, back in early 2007, I had a blog post about JSF Page Templates - Templating in Oracle JDeveloper 11g. First technical preview for JDeveloper/ADF 11g was just released and it was my first blog post about 11g version. It was exciting time - I was writing it while flying somewhere between Norway and Denmark. We keep forgetting good things and remember only bad, but just think about - JDeveloper 11g is referencing ADF libraries from ADF Runtime module, but in 10g we were copying these libraries into every application, WEB-INF folder. Yes..., I'm happy to work with 11g.

Today I will return to JSF Page Template topic and will describe how you can apply it for JSF Page Fragments and improve reusability across your system. Typically we apply JSF Page Template for JSF Pages, but there are many use cases when templates can be applied for JSF Page Fragments (when using ADF Regions). Download sample application - FragmentTemplate.zip.

This application implements JSF Page Template with Query Criteria and area for results data:


JSF Page Template is mapped with Page Definition for Query Criteria executables:


As you already know, Query Criteria returns search result into component defined by Result Component Id attribute. Result data collection will be defined inside JSF Page Fragment created based on our template. This means, from consuming JSF Page Fragment we need to pass information about Result Component Id into JSF Page Template and define it for Query Criteria:


JSF Page Template must declare attribute for Result Component Id, to pass value from consuming JSF Page Fragment:


This attribute will be referenced from Query Criteria:


Application implements two JSF Page Fragments, each of them is based on JSF Page Template with Query Criteria. One JSF Page Fragment provides simple Search form, another Master-Detail relationship:


If we want to preserve JSF Page Template Query Criteria parameters, when switching between different JSF Page Fragments - Query Criteria VO implementation class needs to be overridden:


Override executeQuery() method, and call saveState() function to ensure that Query Criteria parameters are saved when we are navigating between different instances of the same Query Criteria:


Main page contains two tabs, each tab renders different JSF Page Fragments, these fragments are implemented based on JSF Page Template. Query Criteria is coming from JSF Page Template:


This allows to reuse the same Query Criteria for different JSF Page Fragments. For example, user can search:


Open another JSF Page Fragment with Master-Detail and use the same Query Criteria - no need to implement it twice:


Perform another search:


Same Query Criteria will be applied again, now for the first tab:

4 comments:

Ramesh Chandra said...

Hi Andre,

I am using Jdev 11.1.1.3.0 to run this sample but facing some issue

10:33:41 AM] #### Deployment incomplete. ####
[10:33:41 AM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)
#### Cannot run application FragmentTemplate due to error deploying to IntegratedWebLogicServer.
[Application FragmentTemplate stopped and undeployed from Server Instance IntegratedWebLogicServer]

Your help will be highly appreaciated..

Regards,
Ramesh

Andrejus Baranovskis said...

Hi Ramesh,

This sample is developed with exactly same version. It might be, you need to change DB connection for Model project, its why it can't start.

Regards,
Andrejus

Vipin said...

Hi Andre,

In this blog "but just think about - JDeveloper 11g is referencing ADF libraries from ADF Runtime module". Can you please explain a bit more on this. I am a regular visitor to your blogs, and always find them impressive, informative and consize.

Thanks,
Vipin

Andrejus Baranovskis said...

Hi Vipin,

In ADF 10g, every application had a copy of ADF runtime libraries inside. This means if I would send you sample ADF 10g application, archive size would be around 10 MB. Or, I would need to remove these libraries, create archive and ask you to add them later, when you will want to run application.

Thanks,
Andrejus