dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help - this should be easy

  1. #1
    Join Date
    Dec 2002
    Location
    Virginia
    Posts
    5

    Help - this should be easy

    I use a JavaBean and JavaScript as follows:

    <jsp:useBean id="mybean" class="MyClass" scope="session" > <%! int i = 0; %>
    </jsp:useBean>

    then some JSP and HTML...

    <table>
    <% int rowCount = 0;
    int startRow = 0;
    String start = (String) request.getParameter("start");
    startRow = new Integer(start).intValue();
    mybean.setStartRow(startRow);
    while (rowCount < 100 && mybean.nextRow() > 0) {
    %>

    then I output the table rows..., then:

    <% i++;
    rowCount++;
    }
    %>
    </table>

    then I have a Back and Next button pair, and this is where the problem is:

    <a href="<%= request.getContextPath() %>/jsp/this.jsp?start=<%= (startRow > 99) ? startRow - 100 : 0 %>"
    onclick="javascript:<% i = i - startRow; %> return true;">
    Back</a>

    <a href="<%= request.getContextPath() %>/jsp/this.jsp?start=<%= mybean.getCurrentRow() %>">
    Next</a>


    The problem is a NullPointerException with setStartRow, but if I take out the onclick code, it almost works; it just doesn't decrement the i counter when I go back.

    How do you make this work so the i counter gets decremented when you hit the back button?

    Thx

  2. #2
    Join Date
    Dec 2002
    Location
    Virginia
    Posts
    5
    C'mon guys, noone knows this??? I can't get it to work and wish I could get some help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles