codeconsole opened a new pull request, #16272:
URL: https://github.com/apache/grails-core/pull/16272

   A `resource` link derives its controller from the domain class name, so a 
controller not named after its domain class is never found:
   
   ```groovy
   class PeopleController extends RestfulController<Person> {
       PeopleController() { super(Person) }
   }
   ```
   
   ```gsp
   <g:link resource="${person}">          <%-- targeted "person", which does 
not exist --%>
   <g:link controller="people" action="show" id="${person.id}">   <%-- the 
workaround --%>
   ```
   
   `DefaultLinkGenerator` now keeps a domain-class-to-controller index 
alongside the existing namespace index, built lazily and guarded by the same 
artefact-array identity check, so it costs nothing on the common path and 
rebuilds on a development-mode reload.
   
   A controller's domain class is resolved by walking its superclass hierarchy 
for a generic type argument the mapping context recognises as a persistent 
entity. That covers any generic REST base class at any depth without this class 
depending on that hierarchy:
   
   ```groovy
   class PeopleController extends RestfulController<Person> {}          // 
resolved
   class WidgetsController extends WidgetControllerBase {}              // 
resolved through the base
   abstract class WidgetControllerBase extends RestfulServiceController<Widget> 
{}
   ```
   
   Resolution applies only when exactly one controller declares the domain 
class. An ambiguous or absent declaration falls back to the previous behaviour, 
so the change is additive.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to