Implementing a Custom Filter

You can define and implement a custom filtering scheme for a table page.

  1. Create a custom JSP page to access the table data and do the filtering based on the user input.

    This graphic shows an example of a custom filter implemented on a table page.



    The custom JSP page gets an input request parameter "tableID." Read this parameter from the request object. This parameter is the key to obtain the current table data.

  2. Using the table ID key, call the table bean methods (described below) to obtain the table data.

  3. The table data contains the complete list of objects and other input parameter details. Process the table data to get a filtered list and set the filtered objects list back in the table data using a bean method.

  4. Refresh the table display page using a JavaScript API.

    The following code is a template that illustrates the custom filtering described above:

    /////////////////// START Code Template /////////////////////
    
    //Declare the table bean with session scope
    
    <jsp:useBean id="tableBean" 
    class="com.matrixone.apps.framework.ui.UITable" 
    scope="session"/>
    
    // Start the JSP code
    
    <%
    
     // Get the table ID from the request
    
     String tableID = Request.getParameter(request, "tableID");
    
    // Obtain the object list for the current table using the 
    tableID
    
    MapList relBusObjList = tableBean.getObjectList(tableID);
    
    // Obtain the requestMap which contain all the request params to 
    emxTable.jsp
    
    HashMap requestMap = tableBean.getRequestMap(tableID);
    
    ?.
    
    // Process the object List and filter it to create a new MapList 
    of filtered object List
    
    MapList filteredObjPageList = ?.
    
    ?
    
    // Set the filtered object list for the current table using the 
    tableID
    
    tableBean.setFilteredObjectList(tableID, filteredObjPageList);
    
    // End JSP code and Start the Javascript code to call the 
    refresh method as below
    
    %>
    
    <script language="JavaScript">
    
            parent.refreshTableBody();
    
    </script>
    
    ///////////// END Code Template ///////////////////////////////