Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to view multiple database records over several pages?

Status
Not open for further replies.

glwinsor

Programmer
Jan 28, 2005
1
CA
Hi,
I am new to struts and JSP and am working on an application that accesses a database and returns multiple records as DTOs (class name "Annotation")into an ArrayList.

Within my Action class:

ArrayList resultList=new ArrayList();
resultList= dataAccessObject.getRecords(); // returns an ArrayList of Annotation" objects

The ArrayList is then placed as an attribute in the session object:

HttpSession session=request.getSession();
session.setAttribute("resultList",resultList);

I then access the ArrayList in the JSP page as:

<logic:iterate id="resultList" name="resultList" scope="session" type="search.Annotation" >
<td width="70"> <bean:write name="resultList" property="genome"/>(Chr <bean:write name="resultList" property="chromosome"/>) </td>
<td width="48"> <bean:write name="resultList" property="geneName"/></td>
<td width="120"> <bean:write name="resultList" property="productName"/> </td>
<td width="83"> <bean:write name="resultList" property="start"/></td>
<td width="50"> <bean:write name="resultList" property="stop"/></td> </tr>
</logic:iterate>

The above code works fine, however several hundred results can be returned and I would like to view/navigate around 20 of them at a time (similar to google results). I am familiar with the <html:iterate> tag's 'offset' and 'length' attibutes and am wondering what the best approach would be to dynamically set this value. I would be open to completely different approaches to solving this problem as well and appreciate any suggestions.
Thanks,
Geoff
 
hallo,

in my opinion, the best choice for you is to use the displaytag library. this is a jsp taglib who renders an html table an display datas from different java source such beans or directly from an resultset. page function is only on feature of this create library. you can export to differnt formats or create dynamic links. sorting, paging and so one are supported to.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top