Hi,
I have a Path stored in the localStorage of my browser and would like to use it to test a path condition in Sightly.
Can you please let me know if this can be accomplished? If Yes, a prototype of the code would help.
Thanks in advance.
Regards,
Sagar
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Sagar,
Reading localstorage directly in sightly is not possible. Localstorage is a related to client side and passing that value to directly to sightly is not possible. You might have to write some servlet :
Make an ajax call in the component like below:
var url = "/bin/someservlet?localstorageval=" + localStorage.getItem("somelocalstorage") + "&resourcepath="+${resource.path}
In the servlet you can set the value of the localstorage to the resource path, which we are passing to the servlet.
Now you can access the value as ${properties.whatevervalue}
whatevervalue = This is the value which you set to the resource(component resource).
This is not a good solution but this is what I got it in my mind.
You can add a hidden field to you dialog and set some default value to it.
This might not work on the first load because ajax call will be done after sightly it already loaded.
See this News Component using Guardian News API in AEM | Adobe AEM Club
edubey any help?
~kautuk
Views
Replies
Total Likes
Hi Sagar,
Reading localstorage directly in sightly is not possible. Localstorage is a related to client side and passing that value to directly to sightly is not possible. You might have to write some servlet :
Make an ajax call in the component like below:
var url = "/bin/someservlet?localstorageval=" + localStorage.getItem("somelocalstorage") + "&resourcepath="+${resource.path}
In the servlet you can set the value of the localstorage to the resource path, which we are passing to the servlet.
Now you can access the value as ${properties.whatevervalue}
whatevervalue = This is the value which you set to the resource(component resource).
This is not a good solution but this is what I got it in my mind.
You can add a hidden field to you dialog and set some default value to it.
This might not work on the first load because ajax call will be done after sightly it already loaded.
Views
Likes
Replies