Reputation: 51
index.gsp:
<g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }">
<li class="controller"><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li>
</g:each>
This creates a list of all existing controllers. What I need is list of only a few, specific controllers. Is there a way to accomplish that?
For example: my application has 17 controllers, all of them are displayed. I want just 5 to be displayed.
Upvotes: 0
Views: 1544
Reputation: 3881
You could add a static variable to your controller to determine if the controller should appear in your gsp.
In Controller:
static Boolean linkMe = true
In GSP:
<g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }">
<g:if test="${c.getStaticPropertyValue('linkMe', Boolean)}">
<li class="controller">
<g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link>
</li>
</g:if>
</g:each>
Upvotes: 3
Reputation: 187339
If (for example) you only want UserController
and LoginController
to be displayed
<g:each var="c" in="${[UserController, LoginController]}">
<li class="controller">
<g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link>
</li>
</g:each>
Remember to import the classes for these controllers into the GSP.
Upvotes: 1