AEM - Fetching Multifield Values Using Sling Model | AEM Community Blog Seeding | Community
Skip to main content
kautuk_sahni
Community Manager
Community Manager
July 23, 2020

AEM - Fetching Multifield Values Using Sling Model | AEM Community Blog Seeding

  • July 23, 2020
  • 0 replies
  • 10955 views

BlogImage.jpg

AEM - Fetching Multifield Values Using Sling Model by Bimmisoi Blog

Abstract

In 6.4 and above multifield values get stored as a node. In order to fetch those values in sling models earlier we used to write methods which include node/resource iterators, but now there is a simple and quick way to do so.

Lets see how to do that :
Let us suppose we have created a mulfield named "socialLinks " which has "socialMedia" & "socialMediaLink" properties.

Now in order to read these properties, create a model class for your component which has socialLinks as a multifield .

@Model(adaptables = Resource.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class Model {

/** The social links. */
@Inject
private List socialLinks;

/**
* Gets the social links.
*
* @return the social links
*/
public List getSocialLinks() {
return new ArrayList<>(socialLinks);
}

}

Create another class named SocialLinkModel.java and get value of "socialMedia" & "socialMediaLink" using inject or valueMap.

Read Full Blog

AEM - Fetching Multifield Values Using Sling Model

Q&A

Please use this thread to ask the related questions.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.