Subject: Re: CachedRowset with logic:iterate tag From: "Vic C." <[EMAIL PROTECTED]> === I have extendend and made cached row set work with the iterator. See webPIM on sourceforge, basebeans.com or downloads.com
David Chu wrote: > Hi, > When first using struts, I first tried to use a CachedRowSet object as well. > However, based on other people's recommendations, I just went with a simple > Vector of Beans, one representing each row in the ResultSet. It is true > this is more overhead, but no one has extended the CachedRowSet to have an > iterator which is what is necessary. > > It is not necessary to use struts tags; you can use scriplets. But it is so > nice to just use the struts tags. You can achieve almost all of the same > functionality and it looks more like an html page. > > > -david > > ------------------------------ > David C. Chu > America Online > Network Tools Intern > ------------------------------ > > "aps olute" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED]... > >>How to iterate over a CachedRowSet using >><logic:iterate > tags? I have filled the CachedRowset >>with a select >>statement and am able to iterate using the >>crs.getString(1) or the crs.getString(colname) >>methods, >>but no am ready to use Struts tags but dont know how. >>Do I need to convert it a Collection type? but that >>will eat up more memory as two copies CRS and the >>Collection with same contents? >>Is it necessary to use the Struts tags to work with >>the rest of the Struts features? >> >><?xml version="1.0"?> >><%@ page language="java" %> >><%@ page contentType="text/html" %> >><%@ page >>import="sun.jdbc.rowset.CachedRowSet,javax.naming.InitialContext"%> >><jsp:useBean id="Contacts" >>class="sun.jdbc.rowset.CachedRowSet" scope="session"> >><% InitialContext ctx = new InitialContext(); >> javax.sql.DataSource ds = >>(javax.sql.DataSource)ctx.lookup("java:/DefaultDS"); >> java.sql.Connection con = ds.getConnection(); >> Contacts.setCommand("SELECT name, >>owner,species,sex,birth,death from pet"); >> Contacts.execute(con); >> Contacts.first(); %> </jsp:useBean> >><logic:present name="Contacts" property="name"> >><logic:iterate id="subs" name="Contacts" >> type="sun.jdbc.rowset.CachedRowSet"> >> <bean:write name="subs" property="name"/> >></logic:iterate> >></logic:present> >> >> >>But nothing is ever printed. if i take out the >>logic:present and logic:iterate and replaced with a >>while (Contacts.next() Contacts.getString(1) at >>least >>i gets some output. >> >> >> >> >>__________________________________________________ >>Do You Yahoo!? >>Yahoo! Autos - Get free new car price quotes >>http://autos.yahoo.com >> >>-- >>To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > >>For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

