Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 2.0.1
-
Fix Version/s: 2.0.4
-
Component/s: View technologies
-
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…"/></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
- relates to
-
GRAILS-9103
Using url converter interferes on <g:include /> tag, controller/action naming conventions are affected
-
-
GRAILS-8570
g:set not always setting variable in g:include
-
Inshort - include is broken when called from within <g:applyLayout>