开发者

How do define default display order with derived domain classes in Grails?

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 alw开发者_运维知识库ays 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜