Break ArrayList and display in Struts 1

I am facing a display issue ArrayList

that contains 2750 lines. String code to display string:

<c:forEach items="${customerlist}" var="beneficiaryListval"varStatus="ForIndex" >
<tr id="<c:out value="${beneficiaryListval.customerId}" />">
  <td><c:out value="${beneficiaryListval.fullName}" /></td>
    <td><c:out value="${beneficiaryListval.mobileNo}" /></td>
<td><c:out value="${beneficiaryListval.passportNo}" /></td>
    <td><c:out value="${beneficiaryListval.beneficiaryCount}" /></td>
</tr>
<%rowID++;%>
</c:forEach>

      

The action method for this:

public ActionForward load(ActionMapping actionMapping,ActionForm     actionForm,HttpServletRequest httpServletRequest,
        HttpServletResponse httpServletResponse) {
try {
mtmrsLogger.entering("BeneficiaryAction", "load");
BeneficiaryForm beneficiaryForm = (BeneficiaryForm) actionForm;
ArrayList customerlist = customerManager.getCustomerForBeneficiaryWithCount();
httpServletRequest.setAttribute("customerlist", customerlist);
beneficiaryForm.setPageStatus("CustomerGrid");
return actionMapping.findForward(Constants.getInstance().SUCCESS);
}

      

Now I need to either break ArrayList customerlist

or send the JSPs in chunks of fifty, and render OR render them in the JSP so that it is not very slow when rendering.

+3


source to share


4 answers


Saving 2750 entries in the list is not recommended. Think about its implications when you read it from the database / store as well as when you transfer it to your web server. Also, you may not need all of them in one go.

Please consider fetching and displaying data in chunks like 100 at a time. You can always make a new call to the server to get the next set of records by passing in the index.



Also you will have to use Ajax if you are not already using; this way you can keep adding the remaining data to the page without refreshing.

+2


source


I would suggest using a pagination mechanism so that you load 50 or 100 records at a given time. look at extremetable



0


source


The Struts<logic:iterate>

tag has the offset

and attributes length

that can be used to display the sections of the collection. The example below will display the first 50 items in ArrayList

.

<logic:iterate name="customerlist" id="customer" indexId="customerNum" offset="0" length="50">
    <tr id="${customer.customerId}">
        <td>${customer.fullName}</td>
        ...
    </tr>
</logic:iterate>

      

0


source


You cannot split the list customerlist

into "send in jsp chunks". Instead, you can split the method that will return a given number of records, i.e. customerManager.getCustomerForBeneficiaryWithCount(perPage);

, or use JSP boolean tags to constrain rendering strings using two parameters firstRow

and perPage

.

0


source







All Articles