Java - map a list of objects to a list with values of their property attributes

You could do it in a one-liner using Commons BeanUtils and Collections:
(why write your own code when others have done it for you?)

import org.apache.commons.beanutils.BeanToPropertyValueTransformer;
import org.apache.commons.collections.CollectionUtils;

...

List<Long> ids = (List<Long>) CollectionUtils.collect(viewValues, 
                                       new BeanToPropertyValueTransformer("id"));

We can do it in a single line of code using java 8

List<Long> ids = viewValues.stream().map(ViewValue::getId).collect(Collectors.toList());

For more info : Java 8 - Streams