10 Replies Latest reply on Jul 27, 2017 10:58 AM by davids23429739

    How to pass a variable (not hardcoded value) to a data-sly-use statement.


      Hello Guys,


      I've got an issue in which I'm unable to pass a variable to a data-sly-use.


      This is a small snippet of the code I have.


      <div data-sly-use.info="questions-and-answers.js"  data-sly-use.questions="${'LatestQuestions' @ maxLinks=info.maxLinks}" class="nc-questions-and-answers">
        <h2 class="nc-questions-and-answers__heading">




      Basically the first data-sly-use (questions-and-answers.js) returns an object with several properties in which one of those (maxLinks) needs to be send to the second data-sly-use. The problem is that when I tried to get the variable in the java handler I'm always getting null.


      String maxLinks = get("maxLinks", String.class);


      The variables maxLinks is always null.


      If instead of sending `info.maxLinks` I use a hardcoded value like a string or number, I do get the correct value in the Java handler but because the maxLinks property is dynamic then I need to send it like that.


      Does anyone know how to proceed here?


      Thank you.