protected function generateDataRequest(WebRequest $request, TableAbstract $table, $numberOfEntries)
    {
        $sortBy = 'name';
        $sortByDirection = 'ASC';
        
        // If the session has a data request object for the table, load it and refresh the data.
        $savedDataRequestKey = get_class($table) . '.DataRequest.Saved';
        $dataRequest = false;
        if ($table->shouldSaveDataRequest() && $request->getSessionData($savedDataRequestKey) !== false) {
            $dataRequest = unserialize($request->getSessionData($savedDataRequestKey));
        }
        
        // Check if the data request is valid
        if ($dataRequest === false) {
            $dataRequest = new DataRequest(1, $numberOfEntries, $sortBy, $sortByDirection);
        }
        
        // Save the data request to the session if needed
        if ($table->shouldSaveDataRequest()) {
            $request->setSessionData($savedDataRequestKey, serialize($dataRequest));
        }

        return $dataRequest;
    }