View Full Version : Cannot render template in index.gsp

22-03-2016, 12:09 AM

I created a GSP called showTomorrowsReservations.gsp that was a copy of my index.gsp but with an additional section that called an action in the reservation controller to show reservations I had that started tomorrow. I got that working fine when accessing via reservation/showTomorrowsReseravations url. So I decided to try take the code I wanted to show (that was additional to the original index.gsp) and put it in a template called _showTomorrowsReservations.gsp and call this from the index with the line

<g:render template="/reservation/showTomorrowsReservations" model="[reservationsList:reservationsList]" /> (ive also tried a few variation of the model with quotes, etcto see if that was the issue)

but I always get the error:

org.codehaus.groovy.grails.web.mapping.exceptions. UrlMappingException
Unable to create URL for mapping [/(*)/(*)?/(*)?(.(*))?] and parameters [{sort=id, order=desc, action=list}]. Parameter [controller] is required, but was not specified!

The code works when using the /reservation/showTomorrowsReservations url so I know teh controller code is correct but I will port here also to give the whole picture

Reservation Controller Action Code:

def showTomorrowsReservations(){

def today = new Date()
def tomorrow = today +1

List<Reservation> reservationsList = Reservation.findAllByStartDateBetween(today, tomorrow, [max:50, offset:0])


_showTomorrowsReservations.gsp Code:

<%@ page import="net.XXXXXtours.Reservation" %>
<div id="list-tomorrowsreservations" class="content scaffold-list" role="main">
<center><h3> TOMORROWS RESERVATIONS </h3></center></br>

<g:sortableColumn property="id" defaultOrder="desc" title="PO Code" />
<g:sortableColumn property="wocode" title="WO Code" />
<g:sortableColumn property="startDate" title="Start Date" />
<g:sortableColumn property="endDate" title="End Date" />
<g:sortableColumn property="issueDate" title="Issue Date" />

<g:each in="${reservationsList}" status="i" var="reservation" controller="reservation">

<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:link action="show" id="${reservation.id}">${reservation.customer}</g:link></td>
<td>KT0${reservation.id} </td>
<td>${reservation.wocode} </td>
<td><g:formatDate format=" dd/MM/yy" date="${reservation.startDate}" /></td>
<td><g:formatDate format=" dd/MM/yy" date="${reservation.endDate}" /></td>
<td><g:formatDate format=" dd/MM/yy" date="${reservation.issueDate}" /></td>


Im trying to work out why it is not working and am hoping someone can tell me why. I should also mention that I am using spring security which could be causing the issue? I have added
'/**/reservation/**': ['permitAll'] into the grails.plugin.springsecurity.controllerAnnotations .staticRules in Config.groovy to see if that helps and also have grails.plugin.springsecurity.rejectIfNoRule = false set , but still have errors.