Read out and use node parameters from other components via JS Use API
Hi!
my current task is to read out the properties set in a component and use these values in another component:
I created a common component for some settings like date format or some translations that should be used in other components that are also used on that page.
The user should add another component to that page and the settings made before are being used inside this new component.
For example: If we have a setting for a date format in the settings component this format replaces the standard date format in all other used related components.
Storing these settings works properly via dialog.
But when I try to use an JS approach like:
var newNodePath = "/content/path/to/the/page/jcr:content/settings/"; // existing path
var existingComponentResource = resourceResolver.getResource(newNodePath);
returnObj.translationVenue = existingComponentResource.properties("venueTranslation");
the system returns an org.apache.sling.scripting.sightly.SightlyException saying it can't find the function properties.
I'm not able to get the stored values.
I've also tried the Java way - although I'm on beginner level here.
In this case I fail at integrating the .java file into the component HTML via <sly data-sly-use.settings="Settings" />
Even though the Java file is in the right directory the system throws an error: ...cannot be correctly instantiated by the Use API
Where is my mistake?
Any idea how I can solve this (ideally with Java Script)?
Thanks and best regards
Sebastian