on 02-24-2009 10:50 PM
We are trying to validate the contents of a collection, and are having difficulty accessing individual members.
We have tried both using the iterator
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
Object element = iterator.next();
throw doc.createApplicationException("test",element);
}
And the .get() method of the collection variable that is supplied.
int i;
for (i=0;i<=collection.size();i++) {
throw doc.createApplicationException("test",collection.get(i));
}
collection.size() shows that we have 2 members in the collection, but looping through them appears to return null objects.
Hi All,
Did anyone find an answer to this?
Currently I am trying to access a member of "Event specifications" or "QUESTION_LIST" collection
under SPEC tab in Rfx(RFP).
The problem is that even though the size of the collection is greater than 0 , I get NULL when i try to fetch any member of the same using get(index) method or iterator() method.
The code :-
f = doc.getCollectionMetadata("QUESTION_LIST").get(doc);
//f.get(0) returns null
//String s=f.get(0).getDisplayName(); throws error
Integer size=f.size();
throw doc.createApplicationException("",size.toString());//outputs 3
Thanks & Regards,
Mayank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sean, Martin,
In general, using the iterator or index will return the collection member.
However, I've noticed the problem you have described occuring with specific collections.
For example: RFx Response Line Items, Auction Vendors.
In both the cases, I could see the collection size returns a value > 0. But the individual collection members themselves could not be accessed.
Which collections were you trying to access?
Regards,
Reshma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sean,
First of all, tell me which language and tool u r using for ur coding ?
I used BeanShell Scripting and to print values of a collection is like
iterTest = testCollection.iterator()
for(member : iterTest){
fieldX = member.get(fieldX);
System.out.println("FieldX: "+fieldX);
}
Hope this will help you..
Himanshu Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are simply writing a collection validation script in the E-sourcing web interface, which use Beanshell. No tool per se.
I tried this syntax and I still get an error on the line
fieldX = member.get(fieldX);
internal Error: null variable value
The complete code is
iterTest = collection.iterator();
for(member : iterTest){
fieldX = member.get(fieldX);
System.out.println("FieldX: " + fieldX);
}
collection.size is 2, so I know there's something in there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.