public String getPageFunctions() {
        final StringBuilder sb = new StringBuilder("\n")
            .append("\tvar additionalFormFields = [");
        // The list of additional form fields
        for (final String additionalFormField : additionalFormFields) {
            if (!additionalFormField.equals(additionalFormFields[0])) {
                sb.append(", ");
            }
            sb.append(String.format("'%s'", additionalFormField));
        }
        sb.append("];\n\n");

        sb.append("\tfunction jumpToPage(pageNumber) {\n")
            // Changes the current page number, and submits the form
            .append(String.format("\t\tvar formObject = document.getElementById('%s');\n", PAGINATION_FORM_ID))
            .append(String.format("\t\tformObject.%s.value = pageNumber;\n", REQUEST_PARAMETER_KEY_CURRENT_PAGE))
            .append("\t\tsubmitForm();\n")
            .append("\t\treturn false;\n")
            .append("\t}\n")
            .append("\n");

        sb.append("\tfunction setPageSize(pageSize) {\n")
            // Changes the current page size, and submits the form
            .append(String.format("\t\tvar formObject = document.getElementById('%s');\n", PAGINATION_FORM_ID))
            .append(String.format("\t\tformObject.%s.value = pageSize;\n", REQUEST_PARAMETER_KEY_PAGE_SIZE))
            .append("\t\tsubmitForm();\n")
            .append("\t\treturn false;\n")
            .append("\t}\n")
            .append("\n");

        sb.append("\tfunction toggleColumnOrder(sortColumnNumber) {\n")
            // Orders based on a particular column, reversing the order if that column was already ordered on.
            .append(String.format("\t\tvar formObject = document.getElementById('%s');\n", PAGINATION_FORM_ID))
            .append(String.format("\t\tvar previousSortColumnNumber = formObject.%s.value || '0';\n", REQUEST_PARAMETER_KEY_SORT_COLUMN_NUMBER))
            .append(String.format("\t\tvar previousSortOrder = formObject.%s.value || '1';\n", REQUEST_PARAMETER_KEY_SORT_ORDER))
            .append(String.format("\t\tformObject.%s.value = sortColumnNumber;\n", REQUEST_PARAMETER_KEY_SORT_COLUMN_NUMBER))
            .append(String.format("\t\tformObject.%s.value = parseInt(previousSortColumnNumber) === sortColumnNumber ? 1-previousSortOrder : 1;\n", REQUEST_PARAMETER_KEY_SORT_ORDER))
            .append("\t\tsubmitForm();\n")
            .append("\t\treturn false;\n")
            .append("\t}\n")
            .append("\n");

        sb.append("\tfunction submitForm() {\n")
            // Extracts any of the additional form field values, and adds them to the form before submitting it
            .append(String.format("\t\tvar formObject = document.getElementById('%s');\n", PAGINATION_FORM_ID))
            .append(String.format("\t\tfor(var i = 0; i < %d; i++) {\n", additionalFormFields.length))
            .append("\t\t\tvar field = document.getElementById(additionalFormFields[i]);\n")
            .append("\t\t\tif (field !== null) {\n")
            .append("\t\t\t\tvar formField = formObject[additionalFormFields[i]];\n")
            .append("\t\t\t\tif (typeof field !== 'object' || field.value === '') {\n")
            .append("\t\t\t\t\tformField.disabled = true;\n")
            .append("\t\t\t\t} else {\n")
            .append("\t\t\t\t\tformField.disabled = false;\n")
            .append("\t\t\t\t\tformField.value = field.value;\n")
            .append("\t\t\t\t}\n")
            .append("\t\t\t}\n")
            .append("\t\t}\n")
            .append("\t\t\n")
            .append("\t\tif (formObject['").append(REQUEST_PARAMETER_KEY_PAGE_SIZE).append("'].value === '").append(pageSize).append("') formObject['").append(REQUEST_PARAMETER_KEY_PAGE_SIZE).append("'].disabled=true;\n")
            .append("\t\tif (formObject['").append(REQUEST_PARAMETER_KEY_CURRENT_PAGE).append("'].value === '1') formObject['").append(REQUEST_PARAMETER_KEY_CURRENT_PAGE).append("'].disabled=true;\n")
            .append("\t\t\n")
            .append("\t\tformObject.submit();\n")
            .append("\t\treturn false;\n")
            .append("\t}\n")
            .append("\n");

        // Add mechanisms to auto-submit the form when hitting enter (two mechanisms for different browsers)
        sb.append("\tfunction inputFieldOnKeyDownEventListener(e) {\n")
            .append("\t\tif (e.keyCode === 13) {\n")
            .append("\t\t\tsubmitForm();\n")
            .append("\t\t\treturn false;\n")
            .append("\t\t}\n")
            .append("\t}\n")
            .append("\n");

        sb.append("\tfunction inputFieldOnInputEventListener() {\n")
            .append("\t\tif (this.value === '') {\n")
            .append("\t\t\tsubmitFilterForm();\n")
            .append("\t\t\treturn false;\n")
            .append("\t\t}\n")
            .append("\t};\n")
            .append("\n");

        // Finally, bind the functions to the fields
        sb.append(String.format("\tfor(var i = 0; i < %d; i++) {\n", additionalFormFields.length))
            .append("\t\tvar field = document.getElementById(additionalFormFields[i]);\n")
            .append("\t\tif (field !== null && typeof field === 'object') {\n")
            .append("\t\t\tfield.onkeydown = inputFieldOnKeyDownEventListener;\n")
            .append("\t\t\tfield.addEventListener('input', inputFieldOnInputEventListener);\n")
            .append("\t\t}\n")
            .append("\t}\n");

        return sb.toString();
    }
@return a string containing JavaScript that helps with navigation between pages
xmppserver/src/main/java/org/jivesoftware/util/ListPager.java