ADF Faces: Avoid Use of <jsp:include> Tag!
By Steven Davelaar on Sep 28, 2010
When reviewing ADF applications, I frequently see ADF Faces pages that use the <jsp:include/> tag to include another ADF Faces page fragment.
This is really old-school JSP programming and should be avoided:
- Component id's in the included page fragment might conflict with component id's in the base page.
- You cannot use it as a partial source or partial target in partial page refresh
- You cannot use JSF expression language in the <jsp:param/> since it was designed for JSP, not JSF
- You cannot customize this tag using MDS
It is much better to use the native ADF Faces <af:declarativeComponent> tag, which is a first-class UI Component:
- It is a naming container with its own id property, you will never have id conflicts with the page using the component
- It has a partialTriggers property and can be specified as partial target component by other UI components
- You can pass parameters using custom properties (see below) or the <f:attribute> tag, and you can use JSF expression language to specify parameter values.
- You can customize the component using MDS
So, replace code like this:
<jsp:param name="myParam" value="myValue"/>
<af:declarativeComponent id="dc0" viewId="/includes/myIncludeFragment.jsff" myParam="myValue"/>
Note the use of custom property "myParam" inside the tag, this property should be defined as attribute in the declarative component definition as shown below:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core"
<!-- Actual content goes here-->