Data Providers

Data providers are Java™Beans that provide application-level access to the Java™ APIs for the Content Engine and the Process Engine. Therefore you can change the presentation layer without modifying the data access logic. Query calls return XML. A data provider typically caches its data to the data store.

An instance of a data provider can be associated with one or more data providers or UI modules, and/or the controller. This makes the data provider's cache and other state information visible to one or more objects on the page. If a UI module has an associated data provider, any UI modules that are contained by the parent also have access to this data provider.

The Toolkit includes providers that handle navigation, search, and workflow-related data. Data providers subclass WcmDpModule, and call into the Content Java API or Process Java API. For a list of all of the data providers, see the com.filenet.wcm.toolkit.server.dp package in the Web Application Toolkit Java API Reference.

You can write additional data providers that provide application-level access to other backend sources, such as a database server, mainframe, or other legacy system.

See Also
Toolkit Implementation of MVC
Base UI Modules

Using Data Providers

The following steps outline what you must do to declare and associate a data provider on the event Java™Server Pages (JSP) page.

  1. Declare the DP module in your event JSP, giving it a unique name. For example:

    ...
    <jsp:useBean
       id="myModule"
       class="myPackage.ui.MyUIModule"
       scope="request"/>
    <jsp:setProperty name="myModule" property="name" value="myModule"/>

    <jsp:useBean
       id="navDP"
       class="myPackage.dp.navigationDP"
       scope="request"/>
    <jsp:setProperty name="navDP" property="name" value="navDP"/>


    <jsp:useBean
       id="controller"
       class="myPackage.controller.myController"
       scope="request"/>
    ...
  2. Bind the data provider module to one or more UI modules using the addDataProvider(...) method, derived from WcmDpContainer. For example:

    ...
    <%
       com.filenet.wcm.toolkit.util.WcmString heading = new
          WcmString("server.WcmSignIn_jsp.heading", "Sign In");

       myModule.addDataProvider(navDP);
       controller.configurePage(application, request);
       controller.getHeaderModule().setTitle(heading.toString);
       controller.registerModule(navDP);
       controller.registerModule(myModule);
       controller.handleEvent(application, request, response, true); %>
    %>

    NOTE  The bound data provider is visible to the UI module and any UI modules that it contains.

  3. Access the data provider in your UI module with the queryDataProvider(...) method, derived from WcmDpContainer. For example:

    ...
    public class navUIModule extends WcmUiModule
    {
       private String objectStoresXML;
       ...
       public void onStartPage(HttpServletRequest request,
                               HttpServletResponse response) throws Exception
       {
          navigationDP navDP = (navigationDP)queryDataProvider(navigationDP.TYPE);
          objectStoresXML = navDP.getObjectStores(false);
       }
    }
    ...

The queryDataProvider(...) method checks for direct binding to the UI module, navUIModule in the code fragment above. If the data provider is not bound to navUIModule, it recurses up the containment chain to the UI module to which it is bound, MyUIModule, and an instance of the data provider is returned. This containment relationship is shown in the following diagram.

UI module/dataprovider containment relationship

Best Practices for Creating Data Providers

Follow these guidelines when creating a data provider: