title: Migrating from Sitemesh to Apache Tiles
body: <p>I'm developing my own project using spring-mvc and spring-webflow. After reading some articles about spring webflow and ajax, I understood the better option is the use of Apache Tiles for rendering the view.</p>
  
  <p>In Sitemesh i used a tag call head (). That tag used in the template allows render the entire head attribute of a page rendered on the resulting HTML.</p>
  
  <p>Is there any way to achive this in Apache Tiles? From my readings i presume that i have to do the following:</p>
  
  <p>Two jps, one with the body of the page and another with the head definition. Here is an example with the template, a page and the tiles definition for better understanding.</p>
  
  <p>the tiles definition</p>
  
  <pre><code>&lt;tiles-definitions&gt;
    &lt;definition name="base" template="/WEB-INF/view/templates/tileslayout.jsp"&gt;
      &lt;put-attribute name="title" value="Held - main page"/&gt;
      &lt;put-attribute name="body" value=""/&gt;
      &lt;put-attribute name="head" value=""/&gt;
    &lt;/definition&gt;
  
    &lt;definition name="company.edit" extends="base"&gt;
      &lt;put-attribute name="head" value="/WEB-INF/view/company/editHeader.jsp"&gt;&lt;/put-attribute&gt;
      &lt;put-attribute name="body" value="/WEB-INF/view/company/edit.jsp"&gt;&lt;/put-attribute&gt;
    &lt;/definition&gt;
  
  &lt;/tiles-definitions&gt;
  </code></pre>
  
  <p>the template:</p>
  
  <pre><code>&lt;%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %&gt; 
  &lt;html&gt;
  &lt;head&gt;
   -- css and scripts --
   &lt;tiles:insertAttribute name="head"  ignore="true"/&gt;
  &lt;!--  &lt;decorator:head /&gt; --&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  --- menu definition ---
  
  &lt;div class="container-fluid"&gt;
      &lt;tiles:insertAttribute name="body"/&gt;
  &lt;!--   &lt;decorator:body/&gt; --&gt;
  &lt;/div&gt;
  &lt;hr/&gt;      
  &lt;footer&gt;
      -----
  &lt;/footer&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>a company page</p>
  
  <pre><code>&lt;div class="container"&gt;
  -- the page html code
  &lt;/div&gt;
  </code></pre>
  
  <p>the head company page</p>
  
  <pre><code>&lt;meta name="menu" content="company" /&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;style&gt;
  .error {
      color: red;
  }
  &lt;/style&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $('#name').focus();
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>sometimes the head maybe more complex.</p>
  
  <p>The resulting html is ok. But i don't like to define two jps for something that should be simple.</p>
  
  <p>I'm doing something wrong?</p>
  
  <p>Is there a better way to do this?</p>