when the value of i=0 or i=4, then I want to render the below code so that I can introduce a row.
<%--<div class="row selected-classifieds">
--%>
<g:each in="${shortAds?}" var="item" status="i">
<%
if(i==4 || i==0)
out << '<div class="row selected-classifieds">'
%>
<div class="col-lg-3">
<div class="thumbnail">
<%--<img src="http://placehold.it/800x600/e0e0e0" />--%>
<img height=100, width=100
src="${createLink(controller: 'ImageProcessing', action: 'DisplayImage', params: ['id': item.id])}" />
<div class="caption">
<p>
<small><a href="#"> ${item?.title}
</a></small>
<p>
<p>
<strong> ${item?.price}
</strong>
</p>
</div>
</div>
</div>
<%
if(i==4 || i==0)
out << '</div>'
%>
</g:each>
It is giving me below error message. URI:/Classified/Class:org.codehaus.groovy.control.MultipleCompilationErrorsExceptionMessage:startup failed: C__SpringSource_ProjectClassified_Classified_grails_app_views_classified__adthumbnail_gsp: 21: unexpected token: < @ line 21, column 10. out << ^ 1 error
You could try:
<g:each in="${shortAds?.collate(4)}" var="itemset">
<div class="row selected-classifieds">
<g:each in="${itemset}" var="item">
<div class="col-lg-3">
<div class="thumbnail">
<img height=100, width=100
src="${createLink(controller: 'ImageProcessing', action: 'DisplayImage', params: ['id': item.id])}" />
<div class="caption">
<p><small><a href="#"> ${item?.title}</a></small></p>
<p><strong>${item?.price}</strong></p>
</div>
</div>
</div>
</g:each>
</div>
</g:each>