tags:

views:

125

answers:

1

In Grails 1.2.1, I use a base domain class and derived domain classes and define constraints in all of them. The scaffolding templates (I use the i18n ones) determine the default field display order based on these constraints. My problem: No matter what I do, the fields from the base class are always displayed before the fields from the derived classes.

So here's an example of such classes:

abstract class BaseEntity {

String name
String description
String link

  static constraints = {
    name(blank: false)
    description(blank: true, maxSize: 131072)
    link(url: true, blank: true)
  }
}

class BacklogItem extends BaseEntity {

String type
String priority

  static constraints = {
    name(unique: true)
    type(inList:["Bug", "Enhancement", "New Feature", "Task"])
    priority(inList:["Low", "Medium", "High"])
    description()
    link()
  }
}

Now I'd like the fields to show up in the order as defined in the Item constraints (description and link at the end). But no matter what I do, name, description and link are always the first three fields in create/show/edit, due to the base class, even when I try to force them to the end in the derived class constraints.

How would you solve this?

A: 

I will move the constraints away from the base class and duplicate them in each derived class. This means code duplication, but it allows me to specify the display order in each (derived) class the built-in Grails way.

Karsten Silz