Getting the value of the selected checkbox from datatable in jsp

I am using Java EE.

Here is my JSP:

<form  method="POST" enctype="multipart/form-data"action="<c:url value="submitSelected"/>">
<div class="box-body">
    <table id="example" class="table table-bordered table-striped">
        <thead>
            <tr>
                <th>id</th>
                <th>name</th>
                <th><input type="checkbox" id="checkall" /></th>
            </tr>
        </thead>
        <tbody>
            <c:forEach var="category" items="${categoryList}">
                <tr>
                    <td><c:out value="${category.id}"/></td>
                    <td><c:out value="${category.name}"/></td>
                    <td><input type="checkbox" name="selectedCategory" value="${category.id}" /></td>
                </tr>                           
            </c:forEach>
        </table>
    </div>
    <div class="box-footer" id="hidden-div">
        <button type="submit" id="select" >submit</button>
    </div></form>

Here is my JS:

<script type="text/javascript">
$(document).ready(function () {
    $("#example").dataTable({
        "scrollX": true
    });
    $("#example #checkall").click(function () {
        if ($("#example #checkall").is(':checked')) {
            $("#example input[type=checkbox]").each(function () {
                $(this).prop("checked", true);
            });

        } else {
            $("#example input[type=checkbox]").each(function () {
                $(this).prop("checked", false);
            });
        }
    });
});</script>

I get my values ​​in my servlet using:

String checkboxValues[] = request.getParameterValues("selectedCategory");

I am using datatable in my JSP. My problem is that if my JSP displays more than 1 page and I select several lines from these pages, my servlet only gets values ​​from the displayed page only. How to get all selected values ​​from a servlet? And if I use checkall, how do I get all the values ​​from the servlet?

+4
source share
1 answer

JSP is a fairly simple technology. Any server paging that runs in the JSP is usually controlled by the programmer. JSP does not help you with pagination.

, (, , currentPage, totalPages, rowsPerPage ..), , . ).

, , categoryList. categoryList 1000 , 1000 .

, Action, categoryList. , .

, , , "check-all", .

, , , , URL , , , ..

0

All Articles