내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Passing Attributes to Sling Model via React?

Avatar

Level 3

We have a React component that returns data from the DAM based on the category Tag assigned to it. Is there a way to pass an attribute from React to the sling model and update the model.json with category data to display in React? Or will we have to keep using servlets to achieve this? 

 

주제

토픽은 커뮤니티 콘텐츠를 분류하여 관련성 있는 콘텐츠를 찾는 데 도움이 됩니다.

SPA
1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @gregy68980908, did you consider to pass the value using GET parameter. Sling model has access to request, so you should be able to retrieve GET param value and update data exposed by model respectively, e.g assuming this is url you are using now

/content/we-retail/language-masters/en.model.json

it can be changed to something like that (this is request you will sent from React)

/content/we-retail/language-masters/en.model.json?attribute=value

In your sling model you can access value like this:

@Self
private SlingHttpServletRequest request;

private String attributeValue;

@PostConstruct
protected void init() {
    this.attributeValue = request.getParameter("attribute");
} 

 

원본 게시물의 솔루션 보기

1 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @gregy68980908, did you consider to pass the value using GET parameter. Sling model has access to request, so you should be able to retrieve GET param value and update data exposed by model respectively, e.g assuming this is url you are using now

/content/we-retail/language-masters/en.model.json

it can be changed to something like that (this is request you will sent from React)

/content/we-retail/language-masters/en.model.json?attribute=value

In your sling model you can access value like this:

@Self
private SlingHttpServletRequest request;

private String attributeValue;

@PostConstruct
protected void init() {
    this.attributeValue = request.getParameter("attribute");
}