Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
what is the correct HTL syntax for get the custom attribute in AEM global request object?

I want get the custom attribute in AEM HTL use the request object. this attribute already set to request through javascript use API. like this:

test.js

use(function () {
  request.setAttribute('someKey', 'someValue');
});

test.html

<html data-sly-use.logic="test.js">
<!-- some code ... -->
<body>
  <div>${request.attribute['someKey']}</div>
</body>
</html>

result:

<html data-sly-use.logic="test.js">
<!-- some code ... -->
<body>
  <div></div> <!-- empty -->
</body>
</html>

We can get request attribute without Java? Many thanks.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Since HTL syntax is rather declarative than imperative, calling methods/functions with parameters is not supported. That means you cannot do something like ${request.getAttribute('someKey')}. Unfortunately, the Java HttpServletRequest API does not expose the attributes as a map (it does that for parameters) so you cannot do ${request.attributeMap['someKey']} either, you'll need to fetch the attribute and expose it from your use-object/model.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Though you cannot send request attribute the way you are trying to do right now , you can set that as a variable from your server side JS and access it in your code.

In your test.js

use(function () {
   return {
    someKey: someValue
   };
});

In your test.html

<html data-sly-use.logic="test.js">
<!-- some code ... -->
<body>
  <div>${logic.someKey}</div>
</body>
</html>

This should print the someValue as output for you.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda