Its very easy to fetch values from sling model classes in sightly. Here is the sample example how we can bind the sling and sightly for multicomposite values.
Above is the content screen shot for the multicomposite header menu
Tab will store the properties as label and link. These values are fetched easily using sling model
Sling Model Class:
import javax.inject.Inject;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@Model(adaptables=Resource.class)
public class Header {
@Inject
public Resource multiComp;
}
Sightly Code:
<div class="top-menu" data-sly-use.headerMenu="${'com.shoppingcart.models.Header'}">
<ul data-sly-list=${headerMenu.multiComp.listChildren}>
<li href="${item.link}"> ${item.label}</li>
</ul>
</div>
No comments:
Post a Comment