0

I want to know how to make a domain object or its data available across the system everywhere in grails?

Like sort of syntex do i need to use to make it happen. ATM my app's user object/instance is only available on one of my 3 templates not even any other view.

4

1 回答 1

1

它对这些视图可用的原因是您的控制器正在将模型推送到这些视图。没有什么可以阻止您从您想要的任何控制器/服务中使用您的域。

例如,我可以执行以下操作:

class HomeController {

  def index() {
    def users = User.list()
    render view: "list", model: [users: users]
  }
}

请注意我是如何完全脱离惯例的,但它仍然有效。

于 2013-01-21T22:36:15.027 回答