Cette conversation a été verrouillée en raison de son inactivité. Veuillez créer une nouvelle publication.
Niveau 1
Niveau 2
Se connecter à la communauté
Connectez-vous pour voir tous les badges
Cette conversation a été verrouillée en raison de son inactivité. Veuillez créer une nouvelle publication.
Hi I am trying to convert my existing jsp to htl. I am stuck at preparing valuemapresource which was included in jsp like below
ValueMap vm= new ValueMapDecorator(new HashMap<>());
vm.put("granite:class", "classname");
vm.put("value", value);
vm.put("name", name);
vm.put("text", text);
ValueMapResource valueMapResource = new ValueMapResource(resourceResolver, resource.getPath(), "granite/ui/components/coral/foundation/form/checkbox", vm);
<sling:include resource="<%= valueMapResource %>"/>
I wanted to convert this above snippet to HTL using data-sly-resource. could you let me know how can i be able to prepare this similar resource in htl.
Résolu ! Accéder à la solution.
Vues
Réponses
Nombre de J’aime
Hi Srikanth,
HTL is strictly presentation layer. There is no way to create objects or write any logic in HTL. You need a support class(Sling Model or Use class) to return ValueMapResource object. The returned object can be included in HTL.
-AG
You need to create a java class for this. if you are looking to populate dropdown then the below article may help you.
http://www.coderss.in/how-to-create-dropdown-dynamically-using-granite-datasource-object-in-aem-6-3/
Vues
Réponses
Nombre de J’aime
You can simply create a node in crx/de of required resource type (here : "granite/ui/components/coral/foundation/form/checkbox") . You can add the properties to node, like here you're putting it in ValueMap and you can include that resource using data-sly-resource HTL syntax like below :
<div data-sly-resource="path/to/resource"></div>
For more ways to include resources using HTL please refer : https://docs.adobe.com/content/help/en/experience-manager-htl/using/htl/block-statements.html#resour...
Vues
Réponses
Nombre de J’aime
Looking at the code snippet, I thought it's static one.
Vues
Réponses
Nombre de J’aime
You can use granite data sources for generating the dynamic list / checkbox options. See here :
https://redquark.org/aem/day-17-granite-datasources/
OR you can create a Java WCM Use POJO and manipulate your fields in the same. You can use Node API to create node and add properties dynamically. See here :https://stackoverflow.com/questions/38888773/programmatically-add-node-in-aem
Vues
Réponses
Nombre de J’aime
Hi Srikanth,
HTL is strictly presentation layer. There is no way to create objects or write any logic in HTL. You need a support class(Sling Model or Use class) to return ValueMapResource object. The returned object can be included in HTL.
-AG
Vues
Likes
Réponses