开发者

Grails: Order of view elements in inherited domain object

开发者 https://www.devze.com 2022-12-29 13:10 出处:网络
One can 开发者_运维问答specify the order of view elements in GSP file by specifying it in the validation block of the corresponding domain class. If the lass is inherited, the parameter of parent clas

One can 开发者_运维问答specify the order of view elements in GSP file by specifying it in the validation block of the corresponding domain class. If the lass is inherited, the parameter of parent class is always displayed first. For eg

class A {

string a
String b

static constraints = {
  b()
  a()
 }
}

class B extends A{
String c
String d
static constraints = {
  d()
  c()
  b()  //parameter from the parent
  a()  //parameter from the parent
 }
}

the order is b,a,d,c. How can I make it d,c,b,a not tampering with gsp.

thanks..


In the constraints for class A, define the constraints in the order you want them to be displayed:

static constraints = {
    d()
    c()
    b()
    a()
}

Even if there is no constraint, leave the entry with an empty () to create the order. This only works with scaffolding though.

0

精彩评论

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