单击“下一步”按钮后如何使用jQuery分页显示数据

时间:2013-07-30 03:51:54

标签: jquery jsp servlets oracle10g ejb

我想使用jquery分页来显示数据库记录。我想每页显示10条记录。我在jsp页面中的数据在一个表格中。我想在点击下一步按钮后进入下一个细节设置。如何更改我的代码才能执行此操作?

这是我的ejb代码..

    public Vector getDetails() {

    Vector record = new Vector();

    try {

        Connection con = null;

        con = eventDetails.getConnection();

        PreparedStatement psmt = con.prepareStatement("Select   e.E_ID,e.E_NAME,e.E_VENUE,TO_CHAR(d.D_START_DATE,'MON') ST_MONTH,TO_CHAR(d.D_START_DATE,'DD') ST_DAY,TO_CHAR(d.D_END_DATE,'MON') EN_MONTH ,TO_CHAR(d.D_END_DATE,'DD') EN_DAY,TO_CHAR(d.D_START_DATE,'HH:MIam')ST_TIME, TO_CHAR(d.D_END_DATE,'HH:MIam')EN_TIME FROM EVENTS e ,EVENT_DATE d WHERE e.E_ID=d.D_ID and  d.D_START_DATE > trunc(sysdate) and  rownum<6  ORDER  BY d.D_START_DATE DESC ");

        ResultSet rs = psmt.executeQuery();
        EventDetails row = null;

        while (rs.next()) {
            row = new EventDetails();
            System.out.println(rs.getString("E_NAME"));
            row.setE_id(rs.getInt("E_ID"));
            row.setEname(rs.getString("E_NAME"));
            row.setEvenue(rs.getString("E_VENUE"));
            row.setS_date(rs.getString("ST_DAY"));
            row.setS_month(rs.getString("ST_MONTH"));
            row.setE_date(rs.getString("EN_DAY"));
            row.setE_month(rs.getString("EN_MONTH"));
            row.setStartTime(rs.getString("ST_TIME"));
            row.setEndTime(rs.getString("EN_TIME"));

            record.add(row);
        }



    } catch (SQLException ex) {
        Logger.getLogger(publiEeventsLocal.class.getName()).log(Level.SEVERE, null, ex);
        System.out.println("Exception Occured");
    }
    return record;
}

我的servlet代码是..

    Vector details = publiEevents.getDetails();  
    HttpSession session = request.getSession();
    session.setAttribute("Result",details);
    response.sendRedirect("/xxxx-war/xxx/xxx/xxx.jsp");

我的jsp代码是

              <%
                Vector eventDetails = (Vector) session.getAttribute("Result");
                Iterator it = eventDetails .iterator();

                EventDetails row;

                while (it.hasNext()) {
                    row = (EventDetails) it.next();

             %>

          <table>
             <tbody>

                <tr>
                      <td><%=row.getStartTime()%></td>
                      <td><%=row.getS_month()%></td>
                      <td><%=row.getS_month()%></td>

                </tr>

                <tr>
                    <td><%=row.getS_date()%></td>
                    <td><%=row.getEvenue()%></td> 
                 </tr>
                    </tbody>  
        </table>
             <%
              }

            %>
           <table align="center">
            <tr><td>
         <input type="button" value="Previous" onclick="">
         <input type="button" value="Next" onclick="">
            </td></tr>
           </table>   

1 个答案:

答案 0 :(得分:0)

我没有用EJB做过这件事。但是在ASP.net中,我的getDetails函数执行类似的操作,

getDetails(pageNumber, pageSize = 10){

      skip = pageNumber * pageSize; //pagenumber starts from zero

      queryFromDB().Skip(skip).Take(pageSize);    //queryFromDB returns a list
}

使用pagenumber调用jquery

检查ResultSet是否已跳过并执行功能..