@SuppressWarnings("unchecked") protected void addAttributeSectionsToInquiryView( InquiryView view, DataObjectEntry dataObjectEntry) { // Set up data structures to manage the creation of sections Map<String, Group> inquirySectionsById = new HashMap<String, Group>(); Group currentGroup = createInquirySection("default", dataObjectEntry.getObjectLabel()); inquirySectionsById.put(currentGroup.getId(), currentGroup); ((List<Group>) view.getItems()).add(currentGroup); // Loop over the attributes on the data object, adding them into the inquiry // If we have an @Section notation, switch to the section, creating if the ID is unknown List<Component> items = (List<Component>) currentGroup.getItems(); // needed to deal with generics issue for (AttributeDefinition attr : dataObjectEntry.getAttributes()) { boolean dontDisplay = hasHintOfType(attr.getDataObjectAttribute(), UifDisplayHintType.NO_INQUIRY); dontDisplay |= (attr.getControlField() instanceof HiddenControl); // Check for a section hint // Create or retrieve existing section as determined by the ID on the annotation UifDisplayHint sectionHint = getHintOfType(attr.getDataObjectAttribute(), UifDisplayHintType.SECTION); if (sectionHint != null) { if (StringUtils.isNotBlank(sectionHint.id())) { currentGroup = inquirySectionsById.get(sectionHint.id()); if (currentGroup == null) { String sectionLabel = sectionHint.label(); if (StringUtils.isBlank(sectionLabel)) { sectionLabel = deriveHumanFriendlyNameFromPropertyName(sectionHint.id()); } currentGroup = createInquirySection(sectionHint.id(), sectionHint.label()); inquirySectionsById.put(currentGroup.getId(), currentGroup); ((List<Group>) view.getItems()).add(currentGroup); } } else { LOG.warn("SECTION UifDisplayHint given without an ID - assuming 'default'"); currentGroup = inquirySectionsById.get("default"); } items = (List<Component>) currentGroup.getItems(); } // This is checked after the section test, since the @Section annotation // would be on the FK field if (dontDisplay) { continue; } DataField dataField = ComponentFactory.getDataField(); dataField.setPropertyName(attr.getName()); dataField.setLabel(attr.getLabel()); items.add(dataField); } }
/** * List of <code>Component</code> instances contained in the lower header group * * <p>Convenience method for configuration to get the items List from the lower header group * * @return List<? extends Component> items */ @ViewLifecycleRestriction @BeanTagAttribute(name = "items", type = BeanTagAttribute.AttributeType.LISTBEAN) public List<? extends Component> getItems() { if (lowerGroup != null) { return lowerGroup.getItems(); } return null; }