Grails
  1. Grails
  2. GRAILS-9005

g:include broken - when g:applyLayout is used

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.4
    • Component/s: View technologies
    • Labels:
    • Environment:
      Windows 7, Grails 2.0.1

      Description

      g:include is broken - when views being rendered uses g:applyLayout

      list-layout.gsp

      <!doctype html>
      <html>
          <head>
              <meta name="layout" content="main">        
              <title><g:message code="default.list.label" args="[entityName]" /></title>
          </head>
          <body>
              <a href="#list-state" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
              <div class="nav" role="navigation">
                  <ul>
                      <li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
                      <li><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></li>
                  </ul>
              </div>
              <div id="list-state" class="content scaffold-list" role="main">
                  <h1><g:message code="default.list.label" args="[entityName]" /></h1>
                  <g:if test="${flash.message}">
                  <div class="message" role="status">${flash.message}</div>
                  </g:if>
                  <g:layoutBody/>
              </div>
          </body>
      </html>
      

      country list.gsp

      
      <%@ page import="org.grails.test.Country" %>
      <g:set var="entityName" value="Country" />
      <g:applyLayout name="list-layout">
      			<table>
      				<thead>
      					<tr>					
      						<g:sortableColumn property="name" title="${message(code: 'country.name.label', default: 'Name')}" />					
      					</tr>
      				</thead>
      				<tbody>
      				<g:each in="${countryInstanceList}" status="i" var="countryInstance">
      					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">					
      						<td><g:link action="show" id="${countryInstance.id}">${fieldValue(bean: countryInstance, field: "name")}</g:link></td>					
      					</tr>
      				</g:each>
      				</tbody>
      			</table>
                  <div class="pagination">
                      <g:paginate total="${countryInstanceTotal}" />
                  </div>           
                  <hr> 		
                  <!-- Try removing this include as every this will work fine -->	
      		    <g:include controller="state" action="list"/>
      </g:applyLayout>
      

      state list.gsp

      <%@ page import="org.grails.test.State" %>
      <g:set var="entityName" value="State" />
      <g:applyLayout name="list-layout">
                  <table>
                      <thead>
                          <tr>                    
                              <g:sortableColumn property="name" title="${message(code: 'state.name.label', default: 'Name')}" />                    
                          </tr>
                      </thead>
                      <tbody>
                      <g:each in="${stateInstanceList}" status="i" var="stateInstance">
                          <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">                    
                              <td><g:link action="show" id="${stateInstance.id}">${fieldValue(bean: stateInstance, field: "name")}</g:link></td>                    
                          </tr>
                      </g:each>
                      </tbody>
                  </table>
                  <div class="pagination">
                      <g:paginate total="${stateInstanceTotal}" />
                  </div>            
      </g:applyLayout>
      

      Try accessing /country/list - it would be broken. remove the include and try again - Every thing is fine !
      See the attached bug report for working example

      The code I pasted above isn't clean - I just wrote it to create a bug report.

        Issue Links

          Activity

          Hide
          sudhir added a comment -

          Matthias I will try to get another clean bug report

          Show
          sudhir added a comment - Matthias I will try to get another clean bug report
          Hide
          Eugenio Lattanzio added a comment -

          Any plans to resolve this? any workaround available since it's blocking for me.

          Show
          Eugenio Lattanzio added a comment - Any plans to resolve this? any workaround available since it's blocking for me.
          Hide
          Eugenio Lattanzio added a comment -

          After debuggin a while, i've noticed i had set grails.web.url.converter = 'hyphenated' after disabling it the g:include start working using camelCase named controller.

          So the issue in my case was the g:include used the grails.web.url.converter to name the controllers instead camelCased

          maybe this comment can help somebody having the same issue.

          Show
          Eugenio Lattanzio added a comment - After debuggin a while, i've noticed i had set grails.web.url.converter = 'hyphenated' after disabling it the g:include start working using camelCase named controller. So the issue in my case was the g:include used the grails.web.url.converter to name the controllers instead camelCased maybe this comment can help somebody having the same issue.
          Hide
          Matthias Hryniszak added a comment -

          Can you prepare something that's simple and shows the issue? The bug report attached here is way to bloated.

          Show
          Matthias Hryniszak added a comment - Can you prepare something that's simple and shows the issue? The bug report attached here is way to bloated.
          Hide
          Lari Hotari added a comment -

          I've done some fixes related to g:include handling and I couldn't reproduce the problem in latest snapshot. Please re-test with the latest 2.0.x build and re-open this issue if the problem remains.

          The test app is missing some files and I had to run "grails upgrade" + disable resources plugin to get it running.

          Show
          Lari Hotari added a comment - I've done some fixes related to g:include handling and I couldn't reproduce the problem in latest snapshot . Please re-test with the latest 2.0.x build and re-open this issue if the problem remains. The test app is missing some files and I had to run "grails upgrade" + disable resources plugin to get it running.

            People

            • Assignee:
              Lari Hotari
              Reporter:
              sudhir
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development