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);