Skip to main content

@ChildResource

Dialog Multifield Entries -> include as @ChildResource

ProductList.java

@Model(adaptables = SlingHttpServletRequest.class, adapters = {ProductList.class, ComponentExporter.class}, resourceType = ProductList.RESOURCE_TYPE,
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
@Getter
public class ProductList implements ComponentExporter {

// [...]

@ChildResource
private List<Product> productList;
}

Product.java

@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Getter
public class Product {
@ValueMapValue
private String productId;
@ValueMapValue
private String originalPrice;
@ValueMapValue
private boolean showStrikethroughPrice;
@ValueMapValue
private String additionalPriceText;
}

Loop manually

    private Product[] generateProducts() {
List<Product> slidePojos = new ArrayList<>();
Resource resource = request.getResource();

final Resource slideCollectionItems = resource.getChild(SLIDE_COLLECTION_ITEMS);
if (slideCollectionItems != null) {
for (Resource slide : slideCollectionItems.getChildren()) {
final Product slidePojo = new Product(slide.getValueMap(), request);
slidePojos.add(slidePojo);
}
}

return slidePojos.toArray(new Product[0]);
}