Sample JSPs for Custom Filtering

You can create custom JSPs to implement custom filtering.

Two JSP pages might be required to implement the custom filtering within the configurable table as follows:


  • The first page creates the user interface to initiate the filter.
  • The second page takes the input from the first page and processes the data. It then filters the data and updates the display. Only the first page is assigned as the URL parameter to emxTable.jsp.

Here are samples of both JSPs.

First JSP (for UI): emxTableFilterIncludeSample.jsp

<html>
<%@include file = "../common/emxNavigatorInclude.inc"%>
<jsp:useBean id="formEditBean" 
class="com.matrixone.apps.framework.ui.UIForm" scope="session"/
>
<%
String tableID = Request.getParameter(request, "tableID");
%>
<head>
<link rel="stylesheet" href="styles/emxUIDefault.css" 
type="text/css">
<link rel="stylesheet" href="styles/emxUIList.css" type="text/
css">
<script language="javascript">
    function filterData()
    {
       var filterProcessURL="emxTableFilterIncludeProcess.jsp";
       document.filterIncludeForm.action = filterProcessURL;
       document.filterIncludeForm.target = "listHidden";
       document.filterIncludeForm.submit();
    }
</script>
</head>
<body>
<form name="filterIncludeForm">
<table border="0" cellspacing="2" cellpadding="0" width="100%">
<tr>
<td width="99%">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="pageBorder"><img src="images/utilSpacer.gif" 
width="1" height="1" alt=""></td>
</tr>
</table>
</td></tr>
</table>
<table>
<tr>
<td width="100"><label>State</label></td>
<td class="inputField" ><select name="filterState" id="">
<option value="Preliminary">Preliminary</option>
<option value="Release">Release</option>
<option value="Create"  selected >Create</option>
<option value="Obsolete">Obsolete</option>
</select>
</td>
<td width="50"> &nbsp; </td>
<td width="150"><input type="button" name="btnFilter" 
value="Filter..." onclick="javascript:filterData()"></td>
</tr>
</table>
<input type="hidden" name="tableID" value="<%=tableID%>">
</form>
</body>
</html>

Second JSP (for processing and refreshing): emxTableFilterIncludeSample.jsp

<%@include file = "../common/emxNavigatorInclude.inc"%>
<jsp:useBean id="tableBean" 
class="com.matrixone.apps.framework.ui.UITable" 
scope="session"/>
<%
    String tableID = Request.getParameter(request, "tableID");
    String selectedState = Request.getParameter(request, 
"filterState");
    // Get business object list from session level Table bean
    // HashMap tableData = tableBean.getTableData(tableID);
    MapList relBusObjList = tableBean.getObjectList(tableID);
    HashMap requestMap = tableBean.getRequestMap(tableID);
    MapList filteredObjPageList = new MapList();
    StringList busSelects = new StringList();
    BusinessObjectWithSelectList busObjwsl = null;
    if ( relBusObjList != null)
    {
        String objIdArray[] = new String[relBusObjList.size()];
        busSelects.add("current");
        for (int i = 0; i < relBusObjList.size(); i++)
            objIdArray[i]  = 
(String)((HashMap)relBusObjList.get(i)).get("id");
        busObjwsl = 
BusinessObject.getSelectBusinessObjectData(context, objIdArray, 
busSelects);
        for (int i = 0; i < relBusObjList.size(); i++)
        {
            String currentStatus   = 
(String)busObjwsl.getElement(i).getSelectData("current");
            if (currentStatus != null && 
currentStatus.equals(selectedState) )
                filteredObjPageList.add(relBusObjList.get(i));
        }
    }
    tableBean.setFilteredObjectList(tableID, 
filteredObjPageList);
%>
<script language="JavaScript">
        parent.refreshTableBody();
</script>