Nível 1
Nível 2
Faça login na Comunidade
Faça logon para exibir todas as medalhas
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.
Solucionado! Ir para a Solução.
Visualizações
respostas
Total de curtidas
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..
Visualizações
respostas
Total de curtidas
You can’t directly pass a value from one component to another unless otherwise you are storing the value on page properties instead of components or uses cookie or local storage (not recommended)
Visualizações
respostas
Total de curtidas
i am storing as page property those authored value then how i can achieve
in other component
Visualizações
respostas
Total de curtidas
In other components html you can use pageproperties.fieldName to get the value authored on page. Something similar to ${pageProperties.jcr:title}
Visualizações
respostas
Total de curtidas
@prachiat - Page Properties as suggested by @DPrakashRaj is one way.
But make sure the property is relevant to the page - as coupling a component property to page property is not an ideal design use case.
You can also look at the Shared Component Properties if there is a coupling between 2 components for the data.
Shared Component Properties - ACS Commons
Blog for Reference - AEM Shared Content and Component Properties
Also, you can try out the blog AEM Sharing data between components wherein the parent component sets the data.
In order to access this data you need to very specifically ask for a specific CRX node of a specific resource type with a specific name.
Hope this helps!
Rohan Garg
Visualizações
respostas
Total de curtidas
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..
Visualizações
respostas
Total de curtidas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas
Visualizações
Curtida
respostas