문제

I have 2 domains: user & item + corresponding controllers. There is no link (domains don't have a relationship) between user & item. I need to create a view that displays information from both user & item. For example list all users and items in a single view. How can I achieve that? What would be the right approach?

Thank you.

도움이 되었습니까?

해결책

Grails uses a convention but that convention can easily be broken.

class SomeController {

   def list() {
      def users = Users.list()
      def items = Item.list()
      [users: users, items: items]
   }
}

grails-app/views/some/list.gsp

<ul>
  <g:each in="${users}">
    <li>${it.firstName}</li>
  </g:each>
</ul>

<ul>
  <g:each in="${items}">
    <li>${it.name}</li>
  </g:each>
</ul>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top