0

Using jQuery ajax when click on "Next" I will get list of objects (which contains list of objects internally) without converting that to json and not using any other plugin, how I can render this list to display the table similar to in struts.

Currently I am using a include jsp with only the table to be refreshed with next set of results and replacing the existing table div with new jsp. Can someone suggest any other method to do this.

List of Orders and each order has multiple items. One row represents

Order#  --  Order Date -- Item# -- Item Description

                            1   --  Shirt
1       --  05/21/2012 --   2   --  Pant
                            3   --  Brief

If I have 100 orders per page if I display 25 Orders when I click on "NEXT" button as explained above I will get list of next 25 orders then it should display the next 25.

4

1 回答 1

0

I have used the .load function to refresh the list. Same as given example, No conversion to Json is required.

Action Class

public String 25Orders(){
// get from DB 25 orders
// on Click of next by passing page 2 get next 25 orders
}

public Map<abc, Lis<xyz>> getOrders(){
return objects;
}

.js class

$("a[id=pagination]").click(function(event) {
     $("div").load("fulord",{pageStr:this.name});
});

jsp class

<div id=OrdersTable>
<s:iterator value="Orders">
   <tr>
     <td><s:property value=key.orderNumber/></td>
     <td><s:property value=key.orderDate/></td>
      <td>
        <table> 
           <s:iterator value=items>
            <tr>
             <td><s:property value=itemNumber/></td>
             <td><s:property value=itemDesc/></td>
            </tr>
           </s:iterator>
         </table>
      </td>
   </tr>
</s:iterator>
</div>

NOTE: But I see one problem here if a page has more than one div or if I try to give div ID in js it won't work properly. I am trying to resolve that but as of this is solution I found.

于 2012-06-04T00:20:46.967 回答