Closed amador-duran-toro closed 4 years ago
This is better suited for https://github.com/grails3-plugins/scaffolding/issues. It isn't really a fields plugin issue.
This is better suited for https://github.com/grails3-plugins/scaffolding/issues. It isn't really a fields plugin issue.
You are right. I have posted it in https://github.com/grails3-plugins/scaffolding/issues/43.
Shoud I close this issue?
As written, not a Fields Plugin Issue
In Grails 4.0.3 and Grails 3.3.11, if you have an inheritance hierarchy with an abstract superclass, e.g.
And you populate the concrete classes in
Bootstrap.groovy
, e.g.If you use scaffolding, the index page for
A
shows an empty list instead of a paginated list of 50 objects (25 B objects and other 25 C objects).Apart from that, it shows a new button that generates a
java.lang.InstantiationException
when clicked because it tries to instantiate an abstract class.The workaround for this problem is the following:
index.gsp
is relevant)index.gsp
in the following way:Comment the new button code
Comment the
<f:table>
element and add the following codeWith respect to
<f:table>
attributes:aList
variable originally passed to<f:table>
isnull
.domainClass="mypackage.A"
, it generates ajava.lang.InstantiationException
.properties
attribute must be present and contain the list of properties of the abstract class only. If it is not present, and objects of classesA
andB
appear in the same pagination, aorg.springframework.beans.NotReadablePropertyException
is thrown because<f:table>
tries to read properties of classB
on objects of classC
and viceversa.Apart from that, the
create
andedit
pages are still available forA
. I havegenerated-all
forA
and tried to delete those methods from the generated controller, but my knowledge of Grails is limited and I am having lots of errors with that, so I went back to scaffolding (which is my main reason for using Grails).I think that Grails should not show empty lists for abstract classes in scaffolding, but I do not know if that behaviour is inside the scaffolding controller, the
<f:table>
tag, or harcoded in_table.gsp
.I also think that Grails should not generate
create
andupdate
methods in the scaffolding controllers for abstract classes.