jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: [standard] ResultImpl.getRows() return invalid array
Date Tue, 18 Dec 2001 20:03:53 GMT
Justy,

> Yes, the implementation has 1-based indexing. I wasn't sure which would be
> more confusing, having the first column start at position 1, like in JDBC,
> or at position 0. I can shift everything over by 1 but would that cause
> confusion for people expecting the first column to be at position 1. What
> would be the most likely expected behavior?

Even though the Function Description for the sql library doesn't say
if it should be 1- or 0-based indexing, all the examples assumes 0-based.

I believe it's much more important to have consistency within JSTL than
to be consistent with JDBC (and why they decided to use 1-based indexing,
as the only Java API that do, is a great mystery to me).

After I sent these mails I noticed that you use <c:forEach begin="1" ...> to 
get it to work in the examples; I'm sure that I will not be the first that 
misses this and spend way to much time to figure out what's going on of we 
leave it as 1-based.

Hans
> ----- Original Message -----
> From: "Hans Bergsten" <hans@gefionsoftware.com>
> To: "Tag Libraries Developers List" <taglibs-dev@jakarta.apache.org>
> Sent: Monday, December 17, 2001 5:03 PM
> Subject: Re: [standard] ResultImpl.getRows() return invalid array
> 
> > Hi again,
> >
> > I just noticed that RowImpl has a similar problems with getColumns().
> > It also returns an array with a null element for index 0.
> >
> > Hans
> >
> > Hans Bergsten wrote:
> > >
> > > Hi,
> > >
> > > The getRows() method in the
> > > org.apache.taglibs.standard.tag.common.sql.ResultImpl
> > > class returns an array that's one element to large, with the data
> starting at
> > > index 1 as opposed to index 0:
> > >
> > >     public Row[] getRows() {
> > >         if (rows == null) {
> > >             return null;
> > >         }
> > >
> > >         Row[] rowArray = new Row[rows.size() + 1];
> > >         int index = 0;
> > >         Iterator i = rows.iterator();
> > >         while (i.hasNext()) {
> > >             index++;
> > >             rowArray[index] = (Row) i.next();
> > >         }
> > >         return rowArray;
> > >     }
> > >
> > > I guess this may have been an attempt to do 1-based indexing (as in a
> > > ResultSet), but it doesn't work at all with <c:forEach> since the first
> > > element is null. Please change this to:
> > >
> > >     public Row[] getRows() {
> > >         if (rows == null) {
> > >             return null;
> > >         }
> > >
> > >         Row[] rowArray = new Row[rows.size()];
> > >         int index = -1;
> > >         Iterator i = rows.iterator();
> > >         while (i.hasNext()) {
> > >             index++;
> > >             rowArray[index] = (Row) i.next();
> > >         }
> > >         return rowArray;
> > >     }
> > >
> > > Hans
> > > --
> > > Hans Bergsten           hans@gefionsoftware.com
> > > Gefion Software         http://www.gefionsoftware.com
> > > Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> <mailto:taglibs-dev-help@jakarta.apache.org>
> >
> > --
> > Hans Bergsten hans@gefionsoftware.com
> > Gefion Software http://www.gefionsoftware.com
> > Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:taglibs-dev-help@jakarta.apache.org>
> >
> 
> --
> To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>

-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message