Search code examples
htmlapacheautomationtilesjspx

Access Page Name from Tiles Attribute


Our automation team would like us to 'embed' the page names in a hidden field on our page to help them confirm they have navigated properly.

We use Apache tiles to construct our pages using a frame (header, body, footer) where the body holds most of our content.

Is there a way from within the frame to access what the body element is?

Here is our structure:

<div id="content-wrapper">
  <tiles:insertAttribute name="header" ignore="true" />
    <div id="content" class="container">
      <tiles:insertAttribute name="message" ignore="true" />
      <tiles:insertAttribute name="body" ignore="true" />
    </div>
    <tiles:insertAttribute name="footer" ignore="true" /> 
</div>

Solution

  • I found that I could access the body object as a string and output it as a variable then:

    <c:set var="pageId"><tiles:getAsString name="body"/></c:set>
    <div id="page-id" data-page-id="${pageId}"><!-- --></div>