private void updateAttributes(AssociationValue associationValue, ListGridRecord record) {
   for (AttributeInfo attributeInfo : featureInfo.getAttributes()) {
     Attribute<?> attr = associationValue.getAllAttributes().get(attributeInfo.getName());
     if (attr.isPrimitive()) {
       Object value = attr.getValue();
       if (value != null) {
         if (value instanceof Boolean) {
           record.setAttribute(attributeInfo.getName(), (Boolean) value); // "false" != false
         } else {
           record.setAttribute(attributeInfo.getName(), value.toString());
         }
       } else {
         record.setAttribute(attributeInfo.getName(), "");
       }
     } else {
       AssociationAttributeInfo associationAttributeInfo =
           (AssociationAttributeInfo) attributeInfo;
       String displayName = associationAttributeInfo.getFeature().getDisplayAttributeName();
       Object value = attr.getValue();
       if (value != null) {
         if (displayName == null) {
           displayName = associationAttributeInfo.getFeature().getAttributes().get(0).getName();
         }
         switch (associationAttributeInfo.getType()) {
           case MANY_TO_ONE:
             ManyToOneAttribute manyToOneAttribute = (ManyToOneAttribute) attr;
             Object displayValue =
                 manyToOneAttribute.getValue().getAllAttributes().get(displayName).getValue();
             if (displayValue != null) {
               record.setAttribute(attributeInfo.getName(), displayValue.toString());
             } else {
               record.setAttribute(attributeInfo.getName(), "");
             }
             break;
           case ONE_TO_MANY:
             OneToManyAttribute oneToManyAttribute = (OneToManyAttribute) attr;
             List<String> values = new ArrayList<String>();
             for (AssociationValue assoc : oneToManyAttribute.getValue()) {
               Object o = assoc.getAllAttributes().get(displayName).getValue();
               if (o != null) {
                 values.add(o.toString());
               }
             }
             record.setAttribute(attributeInfo.getName(), StringUtil.join(values, ","));
             break;
         }
       } else {
         record.setAttribute(attributeInfo.getName(), "");
       }
     }
   }
   record.setAttribute(VALUE_HOLDER_RECORD_ATTRIBUTE, associationValue);
 }
  /** Actually create or update the fields. */
  private void updateFields() {
    if (featureInfo != null) {
      // Create a header field for each attribute definition:
      List<ListGridField> fields = new ArrayList<ListGridField>();
      if (idInTable) {
        ListGridField gridField = new ListGridField(ID_NAME, "ID");
        gridField.setAlign(Alignment.LEFT);
        gridField.setCanEdit(false);
        fields.add(gridField);
      }

      for (AttributeInfo attributeInfo : featureInfo.getAttributes()) {
        if (!attributeInfo.isHidden()
            && (attributeInfo.isIdentifying() || allAttributesDisplayed)) {
          fields.add(createAttributeGridField(attributeInfo));
        }
      }
      setFields(fields.toArray(new ListGridField[fields.size()]));
      setCanResizeFields(true);
    }
  }