Sample.js "use strict"; use( function () { var data = {}; data.item = []; data.item.push( { "message": "Message111", "anotherArray": [{ "ID": "1", "val": "1111" }] } ); return data; });
Sightly File.html <p data-sly-use.sample="create-case-form-validations.js"></p> ${sample. item.message} returns nothing ${sample. item } returns message , anotherArray
How can I read the “ID” value of the JS array [anotherArray] using Sightly.
Solved! Go to Solution.
ptK wrote...
ptK wrote...
Sample.js
"use strict";
use( function () {
var data = {};
data.item = [];
data.item.push(
{
"message": "Message111",
"anotherArray": [{
"ID": "1",
"val": "1111"
}]
}
);
return data;
});
Sightly File.html
<p data-sly-use.sample="create-case-form-validations.js"></p>
${sample. item.message} returns nothing
${sample. item } returns message , anotherArray
How can I read the “ID” value of the JS array [anotherArray] using Sightly.
;
Sightly File.html
<p data-sly-use.sample="create-case-form-validations.js"></p>
${sample. item.message} returns nothing
${sample. item } returns message , anotherArray
How can I read the “ID” value of the JS array [anotherArray] using Sightly.
Well for your case you have to modify this a bit.
in java script change
"use strict"; use( function () { var data = {}; data.item = []; data.item.push( { "message": "Message111", "anotherArray": [{ "ID": "1", "val": "1111" }] } ); return data.item[0].anotherArray[0][this.val]; });
and while calling from your HTML.
use
<p data-sly-use.sample="${'create-case-form-validations.js' @ val='ID'}">${sample} </p>
Have you tried the following ?
${sample.item[0].anotherArray[0].ID}
Views
Replies
Total Likes
Although not an Array - but rather an ArrayList returned by a Java method:
List<String> hyperLinks = new ArrayList();
hyperLinks.add("content");
return hyperLinks ;
Sightly:
AEM QueryBuilder Sightly Example:
<div data-sly-test="${properties.search}" data-sly-use.v="com.community.querybuilder.HelloService">
<b>Here are the QueryBuilder results that corrresponds to ${properties.search}:</b>
<ul data-sly-list="${v.files}">
<li>${item}</li>
</ul>
</div>
See: https://helpx.adobe.com/experience-manager/using/sightly_querybuilder.html
Views
Replies
Total Likes
smacdonald2008 wrote...
Although not an Array - but rather an ArrayList returned by a Java method:
List<String> hyperLinks = new ArrayList();
hyperLinks.add("content");
return hyperLinks ;
Sightly:
AEM QueryBuilder Sightly Example:
<div data-sly-test="${properties.search}" data-sly-use.v="com.community.querybuilder.HelloService">
<b>Here are the QueryBuilder results that corrresponds to ${properties.search}:</b>
<ul data-sly-list="${v.files}">
<li>${item}</li>
</ul>
</div>
See: https://helpx.adobe.com/experience-manager/using/sightly_querybuilder.html
I am trying to read the simple JS value from sightly.
If I read it from Java method it would be too much work to read single value.
Is Java method the best option for my scenario ?
Views
Replies
Total Likes
ptK wrote...
ptK wrote...
Sample.js
"use strict";
use( function () {
var data = {};
data.item = [];
data.item.push(
{
"message": "Message111",
"anotherArray": [{
"ID": "1",
"val": "1111"
}]
}
);
return data;
});
Sightly File.html
<p data-sly-use.sample="create-case-form-validations.js"></p>
${sample. item.message} returns nothing
${sample. item } returns message , anotherArray
How can I read the “ID” value of the JS array [anotherArray] using Sightly.
;
Sightly File.html
<p data-sly-use.sample="create-case-form-validations.js"></p>
${sample. item.message} returns nothing
${sample. item } returns message , anotherArray
How can I read the “ID” value of the JS array [anotherArray] using Sightly.
Well for your case you have to modify this a bit.
in java script change
"use strict"; use( function () { var data = {}; data.item = []; data.item.push( { "message": "Message111", "anotherArray": [{ "ID": "1", "val": "1111" }] } ); return data.item[0].anotherArray[0][this.val]; });
and while calling from your HTML.
use
<p data-sly-use.sample="${'create-case-form-validations.js' @ val='ID'}">${sample} </p>
Views
Likes
Replies