Access object initialized in template inside Components

jonathand935543 17-12-2018

Hi folks,

I have this below inside my template and now the coreObject has some public properties I need to access inside a component i am creating is this possible? How can it be done in just sightly?

Template snippet:

<div data-sly-use.coreObject="${'com.tgclass.core.servlets.ViewPolicy' @ PNumber=request.requestParameterMap['PNumber'][0].toString, LName=request.requestParameterMap['LName'][0].toString}" data-sly-test="${coreObject}">

Component snippet

<p><b>Country of Residence:  </b> ${coreObject.GetIsoCountry @ context='unsafe'}</p>.

The reason is I need these components inside Experience fragments to make the whole page authorable even with lots of sightly codes in it.

Thanks!

Mark Solution

Are these answers useful?
Help other community members by marking useful answers as accepted.

Accepted Solutions (0)

Answers (1)

Answers (1)

Arun_Patidar
MVP
17-12-2018

I don't think so if this is possible. What you can do, you can get all the data and save as JSON object.

e.g.

<script>

var coreObject ={

GetIsoCountry:${coreObject.GetIsoCountry @ context='styleToken'},

....

}

</script>

This coreObject variable will be global variable and will be available through out the page scope.