How to set value one authored component to another authored component
suppose i have authored cta component i want this authored value into other component that cards. How i can achive this? as I am New to AEM please Help me on this.
suppose i have authored cta component i want this authored value into other component that cards. How i can achive this? as I am New to AEM please Help me on this.
Hi @prachiat
solution:
Here are some sample snippet you can follow to achieve this.
1- Create Sling Model for your page
@Model(adaptables = Page.class)
public class PageModel{
@Inject
private String ctaText;
public String getCtaText() {
return ctaText;
}
}
2- Create a Sling Model for Card component:
@Model(adaptables = Resource.class)
public class CardComponentModel {
@Self
private SlingHttpServletRequest request;
@ScriptVariable
private Page currentPage;
public PageModel getPageModel() {
return currentPage.adaptTo(PageModel.class);
}
}
3- And by this you can use the page model in your card component HTL : This allows you to use the authored CTA text in your Card component.
<sly data-sly-use.model="com.project.aem.components.CardComponentModel">
<div>${model.pageModel.ctaText}</div>
</sly>
Follow the same in squence to your requirement you will be able to achieve it..
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.