Background: It's well documented in the Oracle documentation that Resource Catalog can be filtered at the resource level and catalog level (link here). Let me re-iterate the details a little bit.
Scenario:This blog is demonstrating how to filter a navigation resource in a navigation model using an arbitrary parameter.
Solution:
1. Create a Java class in your portal project called "NavigationFilter" and implement "oracle.adf.rc.spi.plugin.catalog.CatalogDefinitionFilter". The API includeInCatalog() boilerplate code will be created.
2. Create two portal pages called "SecondPage" and "ThirdPage". Assign anonymous access to those page via jaza-data.xml.
3. Drag the two pages into the default-navigation-model.xml file. Define a parameter in the URL parameters section called "showFlag" and assign a value "Y" to the SecondPage, and "N" to the ThirdPage.
4. Copy the following code into the NavigationFilter Java class:
public boolean includeInCatalog(CatalogElement catalogElement, Hashtable hashtable) {
if (catalogElement.getId()!= null && !catalogElement.getId().equalsIgnoreCase("pages")) {
ElementParameters params = catalogElement.getLocalParameters();
if (params != null) {
String param = params.get("showFlag").getValue();
if (param != null && param.trim().equalsIgnoreCase("Y")) {
return true;
} else {
return false;
}
}
}
return true;
}
5. At the default navigation model root level, define the Navigation Filter as the NavigationFilter Java class.
6. Run the app. Now you can see the SecondPage link will be rendered but not the ThirdPage link.
The Demo app can be downloaded here (Built on JDev 11.1.1.7)
- Resource level: there is a "visible" property that takes expression language as a value, which are evaluated at the run time as boolean value to determine whether the particular resource should be displayed or not. The value can be "#{true}", "#{false}" or any other valid EL.
- Catalog level: we can define a Java Bean (a filter class) implementing CatalogDefinitionFilter to apply on a catalog.xml file. In this Java file, we need to implement the API includeInCatalog() which takes two arguments: catalogElement and hashtable objects. The filter class is triggered when the catalog is instantiated.
Scenario:This blog is demonstrating how to filter a navigation resource in a navigation model using an arbitrary parameter.
Solution:
1. Create a Java class in your portal project called "NavigationFilter" and implement "oracle.adf.rc.spi.plugin.catalog.CatalogDefinitionFilter". The API includeInCatalog() boilerplate code will be created.
2. Create two portal pages called "SecondPage" and "ThirdPage". Assign anonymous access to those page via jaza-data.xml.
3. Drag the two pages into the default-navigation-model.xml file. Define a parameter in the URL parameters section called "showFlag" and assign a value "Y" to the SecondPage, and "N" to the ThirdPage.
4. Copy the following code into the NavigationFilter Java class:
public boolean includeInCatalog(CatalogElement catalogElement, Hashtable hashtable) {
if (catalogElement.getId()!= null && !catalogElement.getId().equalsIgnoreCase("pages")) {
ElementParameters params = catalogElement.getLocalParameters();
if (params != null) {
String param = params.get("showFlag").getValue();
if (param != null && param.trim().equalsIgnoreCase("Y")) {
return true;
} else {
return false;
}
}
}
return true;
}
5. At the default navigation model root level, define the Navigation Filter as the NavigationFilter Java class.
6. Run the app. Now you can see the SecondPage link will be rendered but not the ThirdPage link.
The Demo app can be downloaded here (Built on JDev 11.1.1.7)
Comments