1

I have created a list with result set values in which each column element is separated with :: and more than 50 rows using the java code given below.(arr1 is the array list and temp is a String)

int j=0;
while(resultSet11.next()){
   temp=((++j)+"::"+resultSet11.getString("productname")+"::"+resultSet11.getString("exp")+"::"+resultSet11.getString("batch")+"::"+resultSet11.getString("qty")+"::"+resultSet11.getString("foc")+"::"+resultSet11.getString("mrp")+"::"+resultSet11.getString("rate")+"::"+resultSet11.getString("amount")+"::"+resultSet11.getString("taxper")+"::"+resultSet11.getString("taxamount")+"::"+resultSet11.getString("nettaxamount")+"::") ;
                            
   arr1.add(temp);
   rowcount++;
            
   bean.setFirstarray(1);
                        
}
request.setAttribute("nextpagedetails", arr1);

Then I iterated this array list to get these values in a HTML table using the below code.

<table>
<s:iterator var="stat" value='#request.nextpagedetails' >
 <tr>   
   <s:iterator status="arr" value="#stat.split('::')" var="des">       
   <td>
     <s:property value="#des"/>
   </td>
  </s:iterator>
 </tr>
</s:iterator>
</table>

But the problem is this iteration wont stop untill the values in the list ends. Since I am using this table in a print page, there is more than one page. So the second page is coming only after filling the entire portion of of the first page. Is there any way to limit the number of rows in a page using this method.

enter image description here

Roman C
  • 49,761
  • 33
  • 66
  • 176
Anas
  • 173
  • 1
  • 4
  • 20
  • I'm not completely sure what you really want because the printer must detect that the HTML `` needs to be split in several pages. Maybe you want to use `` to detect how many rows have been already written as HTML and then want to create a new table.
    – Luiggi Mendoza Jan 08 '18 at 05:54
  • What database are you using for returning the result set? – Roman C Jan 08 '18 at 15:52

2 Answers2

0

You can try with below code using index property of status variable.

<table>
<s:iterator var="stat" value='#request.nextpagedetails' >
 <tr>   
   <s:iterator status="arr" value="#stat.split('::')" var="des">
       <s:if test="#arr.index <=50">       
            <td>
                <s:property value="#des"/>
            </td>
        </s:if>
  </s:iterator>
 </tr>
</s:iterator>
</table>
Roman C
  • 49,761
  • 33
  • 66
  • 176
0

May be you want to know how many rows you need to render on the view. You can use a parameter in the URL to pass to the action that sublist/subarray values before you return them to the view.

Splitting array/list on multiple pages called a pagination. If you need to learn more about this feature you might read this answer.

Roman C
  • 49,761
  • 33
  • 66
  • 176