Struts/JSP - How would one view multiple database records over severalpages instead of one?

Discussion in 'Java' started by Geoff Winsor, Jan 28, 2005.

  1. Geoff Winsor

    Geoff Winsor Guest

    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
    Geoff Winsor, Jan 28, 2005
    #1
    1. Advertising

  2. Re: Struts/JSP - How would one view multiple database records over several pages instead of one?

    Geoff Winsor wrote
    > 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


    Search in a search engine for

    struts pagination

    There is many open source taglibs for this issue.

    Heiner Kuecker
    Internet: http://www.heinerkuecker.de http://www.heiner-kuecker.de
    JSP WorkFlow PageFlow Page Flow FlowControl Navigation: http://www.control-and-command.de
    Java Expression Formula Parser: http://www.heinerkuecker.de/Expression.html
    CnC Template Technology http://www.heinerkuecker.de/Expression.html#templ
    Domain Specific Languages http://www.heinerkuecker.de/DomainParser.html
    Heiner Kücker, Jan 29, 2005
    #2
    1. Advertising

  3. Geoff Winsor

    Geoff Winsor Guest

    Re: Struts/JSP - How would one view multiple database records overseveral pages instead of one?

    Heiner Kücker wrote:

    Thanks Heiner,
    That was very helpful. I had spent a lot of time searching for this
    using other keywords, but with no success.
    Cheers,
    Geoff


    >
    > Search in a search engine for
    >
    > struts pagination
    >
    > There is many open source taglibs for this issue.
    >
    > Heiner Kuecker
    > Internet: http://www.heinerkuecker.de http://www.heiner-kuecker.de
    > JSP WorkFlow PageFlow Page Flow FlowControl Navigation: http://www.control-and-command.de
    > Java Expression Formula Parser: http://www.heinerkuecker.de/Expression.html
    > CnC Template Technology http://www.heinerkuecker.de/Expression.html#templ
    > Domain Specific Languages http://www.heinerkuecker.de/DomainParser.html
    >
    >
    Geoff Winsor, Jan 29, 2005
    #3
  4. Geoff Winsor

    Ryan Stewart Guest

    Re: Struts/JSP - How would one view multiple database records over several pages instead of one?

    "Geoff Winsor" <> wrote in message
    news:cte7g1$1fu$...
    [...]
    > 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).

    [...]
    Also have a look at the display tag:
    http://displaytag.sourceforge.net/
    Ryan Stewart, Jan 29, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Nietz
    Replies:
    1
    Views:
    3,431
    VisionSet
    Nov 12, 2003
  2. littlebeam
    Replies:
    1
    Views:
    323
  3. Replies:
    7
    Views:
    521
  4. Per Salmi

    Presenting records over multiple rows?

    Per Salmi, Feb 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    8
    Views:
    142
    Jeffrey Tan[MSFT]
    Feb 16, 2004
  5. Parthiv Joshi
    Replies:
    1
    Views:
    643
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page