You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by wb...@Ensign-BickfordInd.com on 2001/12/27 16:38:43 UTC
Problem with iterating a collection of beans
I have a MySQL database with a set of fields:
create table MASTER
(
Number mediumint not null auto_increment,
Requestor char(50) not null,
Title char(150) not null,
Datecreated date ,
Requiredapprovaldate date ,
Targetimplementationdate date ,
Origin char(25) ,
Status char(10) ,
primary key (Number)
) \g
I am using the getCollection to populate a Collection of beans with a
result set. The result set returns the correct data and is putting it
into the map correctly. I do get a correct number of beans back in my
collection. I cannot get the collection to display all of the fields in
my JSP page. I have been twiddling with it for two days and at one
point did have some of the fields displaying correctly (now they are
gone also).
What I have done...
* Double checked all of the field names in the database and the
getter/setter methods in my bean.
* Read the populate API
* Made sure my result set had data
* Tried to get the contents of the bean
According to the populate javadocs, if nothing is overridden it will try
to use the lowercase of the field (capitalize the first letter) and add
set to it. This matches my bean.
When it did work, it only worked for the fields that did not have a
capitalization in the middle (ie: DateCreated) - so I changed the
database. I do not get JSP errors, just blank entries which leads me to
believe that I am getting a bean, but empty.
So, I was trying to dump the contents of the bean with code such as:
MyResultCol = getCollection ( CR ,results);
//Test to iterate through the arraylist we got back
System.out.println("Beans created in ArrayList :" + MyResultCol.size());
for (Iterator i = MyResultCol.iterator(); i.hasNext();) {
System.out.println("Bean has" + (ChangeRequest)i.getOrigin());
}
This code will not compile and tells me it cannot resolve the
getOrigin() symbol. AAARRGGGHHHHH
Any help would be appreciated
Bill Chmura
Ensign-Bickford Industries, Inc.
Information Technologies Department
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>