3 Replies Latest reply on Jan 20, 2012 8:38 AM by Scott Brodersen

    get content of custom component rendtion

    kasq Level 3

      Hi,

       

      I have question related to getting content of custom component rendition.

       

      I have something like contentpage component where I defined contentpage.jsp and test.jsp which creates a custom rendition retrieving from a page only some parts of this page.

       

      For example if I have example.html created from contentpage component like:

       

      <html>

          <head>

          </head>

          <body>

              <div id="ex">Some content example ...</div>

              <div id="ex1">Some content example 1</div>

              <div id="ex2">Some content example 2</div>

          </body>

      </html>

       

      my test.jsp creates only following example.test.html rendition:

       

      <div id="ex1">Some content example 1</div>

       

      My question is - how using CQ API gets in the java code to some String property content of the example.test.html to have something like:

       

      String rendContent = "<div id="ex1">Some content example 1</div>";

       

      Thanks a lot for any answer or suggestion.

       

      Regards,

      kasq

        • 1. Re: get content of custom component rendtion
          Scott Brodersen Adobe Employee

          Could you store the various strings as node properties, and then retrieve the node property from test.jsp?

          • 2. Re: get content of custom component rendtion
            kasq Level 3

            Hi Scott,

             

            I can store this strings as a node property, but how to achieve this? I mean maybe you could give some simple code how to create new property for specific node?

            • 3. Re: get content of custom component rendtion
              Scott Brodersen Adobe Employee

              Say I make a component /apps/geometrixx/components/example:

              • Under the example node, I create another node called examplecontent, of type nt:unstructured.
              • In examplecontent, I create 3 String properties witth the following name/value:
                • example1/The text for example 1
                • example2/The text for example 2
                • example3/The text for example 3
              • example.jsp has the following code that displays the value of the example1 property:

               

              <%--    Example component.  --%><%

              %><%@include file="/libs/foundation/global.jsp"%><%

              %><%@page session="false" %><%

              %>

              <h1>Example page</h1>

              <%=currentNode.getNode("../../../../../apps/geometrixx-outdoors/components/example/examplecontent").getProperty("example1").getString() %>

              </body> </html>