FYI, the JSTL equivalent: import javax.servlet.jsp.jstl.sql.Result; import javax.servlet.jsp.jstl.sql.ResultSupport;
private Result result; public PagedTableBean(Connection conn, String sql, long pageNumber, long pageSize) throws PagedTableException { this.pageNumber = pageNumber; this.pageSize = pageSize; this.conn = conn; this.sql = sql; populateBean(); } private void populateBean() throws PagedTableException { long startRow = (((pageNumber-1)*pageSize)+1); long endRow = (pageNumber*pageSize); String q = "SELECT * FROM (SELECT ROWNUM ROWNO, Q.* " + "FROM (" + sql + ") Q WHERE ROWNUM <= " + endRow + ") WHERE ROWNO >= " + startRow; try { PreparedStatement ps = conn.prepareStatement(q); ResultSet rs = ps.executeQuery(); this.result = ResultSupport.toResult(rs); rs.close(); ps.close(); } catch(SQLException e) { throw new PagedTableException(e.getMessage()); } } public Map[] getRows() { return this.result.getRows(); } public Object[][] getRowsByIndex() { return this.result.getRowsByIndex(); } public String[] getColumnNames() { return this.result.getColumnNames(); } public int getRowCount() { return this.result.getRowCount(); } <bean:define id="results" name="<%= Constants.RESULT_KEY %>" scope="request"/> <c:forEach var="record" items="${results.rows}"> <c:out value="${record.item_number}"> Your item number wasn't provided. </c:out> </c:forEach> Quoting "CRANFORD, CHRIS" <[EMAIL PROTECTED]>: > I don't use the display tags so couldn't tell you. I simply define by bean > using the struts bean:define tag and then access my bean's properties using > the bean:write method or logic taglibs. For example, my table contains a > field called item_number. I access it like as follows: > > <bean:define id="results" name="<%=Constants.RESULT_KEY%>" scope="request"/> > <logic:iterate id="record" name="results" property="rows"> > <logic:empty name="record" property="item_number"> > Your item number wasn't provided. > </logic:empty> > <logic:notEmpty name="record" property="item_number"> > <bean:write name="record" property="item_number"/> > </logic:notEmpty> > </logic:iterate> > > Does this make sense? > Chris > > -----Original Message----- > From: Rajat Pandit, Gurgaon [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 15, 2004 2:49 AM > To: 'Struts Users Mailing List' > Subject: RE: RowSetDynaClass > > > Hey Chris, > Thanks a lot for the detailed information. I have just one more issue, I > have used the RowSetDynaClass (beanutils.jar) and I had this issue where I > couldn't control the position of the column numbers as in the 2 column in > the sql could be anywhere in the resultset returned. I was passing the > collection object back to the display tag. Maybe it internally stores the > metadata information in a Map, or is it something wrong with my > understanding. Do let me know if you have had any such issues before? > Regards rajat > > -----Original Message----- > From: CRANFORD, CHRIS [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 15, 2004 11:46 AM > To: 'Struts Users Mailing List' > Subject: RE: RowSetDynaClass > > > The PagedTableAction class I'm using don't do any client-side or JVM caching > because the data could change relatively quickly depending on the nature of > our business. Thus, for us, letting the database handle the "subset" rownum > limits works well and is very efficient. Right now I can return any subset > of data from a table that contains over 75000 records within < 2 seconds .. > And that's on pagesize ~ 100/150 or so. > > Take care, > chris > > -----Original Message----- > From: Rajat Pandit, Gurgaon [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 15, 2004 2:10 AM > To: 'Struts Users Mailing List' > Subject: RE: RowSetDynaClass > > > Hey navjot, > Thanks for the inputs(any pointers to the documentations (URL) would again > be of great help) I have been pretty happy using the display tag, for small > record sets (about 12000 or so) but I needed something more in case I needed > to customize the pagination stuff. Like caching stuff etc. > Any pointers? > Rajat > (OT (only for navjot) ps: any clue where amit malhotra is these days?) > > > -----Original Message----- > From: Navjot Singh [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 15, 2004 11:38 AM > To: Struts Users Mailing List > Subject: Re: RowSetDynaClass > > if that was really a problem for you, then there could any/both of 2 > reasons. > > 1. You never used ValueListHandler pattern. > 2. You never had used any pager taglib. > > and Chris, you could also look into *sql* JSTL that can help you doing > what you want. And probabaly i recommend using this only for quick > reports generation. > > <navjot/> > > > Rajat Pandit, Gurgaon wrote: > > > Hey Chris, > > This seems like a pretty neat solution you have out here, could please > > explain this, as pagination stuff is kind of the most complicated > > things that I have to deal with and I see my self coding the same > > thing again and again over a period of time. I would really appreciate > > your time and effort. Thanks in adv. > > rajat > > > > -----Original Message----- > > From: CRANFORD, CHRIS [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, June 15, 2004 11:17 AM > > To: 'Struts Users Mailing List' > > Subject: RE: RowSetDynaClass > > > > Found the answer ;-) ... Avoid the <c:...> tags all together and stick > with > > the standard struts tags. The following worked: > > > > <logic:iterate id="row" name="results" property="rows" scope="request" > > indexId="rowid"> > > <bean:write name="row" property="item_id" /> - <bean:write > > name="row" property="item_product_number"/> </logic:iterate> > > > > Now have a fast, efficient paging mechanism that permits me to pass in > > a database connection object, the sql query to execute, starting page > > # and size and it handles the rest by populating itself from the > > database, > closing > > the resultset when finished and leaves the presentation part up to my > > JSP > as > > above! > > > > Gotta love struts! > > Chris > > > > -----Original Message----- > > From: CRANFORD, CHRIS [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, June 15, 2004 12:35 AM > > To: '[EMAIL PROTECTED]' > > Subject: RowSetDynaClass > > > > > > I am storing a RowSetDynaClass property in my java class and I have > > implemented a method on my class as follows: > > > > public Collection getRows() { > > return((Collection)rsdc.getRows()); > > } > > > > In my action, I store my custom class object reference as follows: > > request.setAttribute("results", myResultsObj); > > > > Then in my jsp, I do the following: > > <bean:define scope="request" id="data" name="results" property="rows" /> > > <c:forEach var="row" items="${data}" varStatus="rowid"> > > <c:out value="${rowid.count}"/>. <c:out value="${row.item_id}" /> > > - <c:out value="${row.item_product_number}" /> > > </c:forEach> > > > > I get the following error: > > [ServletException in:/pages/test-body.jsp] > > An error occurred while evaluating custom action attribute "value" > > with value "${row.item_id}": Unable to find a value for "item_id" in > > object of class "org.apache.commons.beanutils.BasicDynaBean" using > > operator "." > (null) > > > > Can someone tell me what I am doing wrong here and how I can do this > > properly to get it to work? > > > > _______________________________________________________ > > Chris Cranford > > Programmer/Developer > > SETECH Inc. & Companies > > 6302 Fairview Rd, Suite 201 > > Charlotte, NC 28210 > > Phone: (704) 362-9423, Fax: (704) 362-9409, Mobile: (704) 650-1042 > > Email: [EMAIL PROTECTED] -- Kris Schneider <mailto:[EMAIL PROTECTED]> D.O.Tech <http://www.dotech.com/> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]