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

Mark Solution

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

해결됨

Sightly

Avatar

Level 2

How to use resource path to get component path. 

/content/myproj/us/en/jcr:content/root/container/container/cloud.container.json?name="+name+"&surname="+surname

I don't want to hardcode my URL in Ajax call. How do I get the component Path and use it in my ajax. 

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

You can get the Content Resource path using ${resource.path}. [/content/myproj/us/en/jcr:content/root/container/container/cloud]
If you need component resource path ${component.path}. [/apps/myproj/components/component]

In Ajax call you won't directly get those variables. You can take a hidden input in HTML and then make the path in JS.

<input type="hidden" value="${resource.path}" />

 

원본 게시물의 솔루션 보기

2 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

You can get the Content Resource path using ${resource.path}. [/content/myproj/us/en/jcr:content/root/container/container/cloud]
If you need component resource path ${component.path}. [/apps/myproj/components/component]

In Ajax call you won't directly get those variables. You can take a hidden input in HTML and then make the path in JS.

<input type="hidden" value="${resource.path}" />

 

Avatar

Community Advisor

Hi @rolliedub 
You can use .-1.json to get the JSON out of resource where resourceType property would be there (which basically is component path).
E.g. If the exact resource path is 

/content/myproj/us/en/jcr:content/root/container/container/cloud

then following url will help you obtain the resource JSON (that includes resourceType)

/content/myproj/us/en/jcr:content/root/container/container/cloud.-1.json

 I'm not sure why you're using ".container". Do you have any custom servlet in place that helps to generate JSON? If so you can use your custom ones as well.

If your component is exposed using Exporter then you can also use .model.json to get the resource JSON.

Best regards,
Himanshu Singhal