Tuesday, July 03, 2012

ViewEntry and Show multiple values as separate entries

When your view has column with option 'Show multiple values as separate entries' and you use ViewEntry to read data from that column you will have a problem. Result of your getColumnValues() can be different, f.x. in 1 case it can be 'Vector' and in another case 'String'. It depends if entry was really split on few entries because of multi-value. I've lookup around and found this issue already reported on IBM ~3 years ago (IBM whats up?)

Full description of problem

Here is a solution I made
Vector v = entry.getColumnValues();
Object o = v.get(0);
String title = "";
if (o.getClass().equals(String.class)) {
 title = (String) o;
}
else if (o.getClass().equals(Vector.class)) {
 Vector tmp = (Vector)o;
 title = (String) tmp.get(0);
}

2 comments :

Mick Moignard said...

Actually it's worse than that. When you access that column, you are actually getting data from the underlying document, and if there are multiple values, you get all of them back. But with no context of which one of them is being displayed on the view row that you are currently cursored on. Utterly and completeley useless.

Dmytro said...

Jesus, true :)
definitely useless.