Announcement Announcement Module
No announcement yet.
Problem with selection in view Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with selection in view

    Hi all,

    Here is a newbee question,

    I want a list of a "domain" in a view like :

    <g:each in="${contractItemInstanceList}" status="i" var="contractItemInstance">

    But now i want to get a list of all contractItemInstance wit a specific I tried everything but no succes...

    Here are the domain classes:

    class ContractItem {
    Customer customer
    Space space

    String contractID

    class Customer {
    String debcode
    String name

    static hasMany = [contactPersons:ContactPerson,contractItems:Contrac tItem]

    in mySql it is : SELECT * FROM `contract_item` WHERE `customer_id`=someValue...

    Who can help me out?



  • #2
    Given a customer id, you can find all related ContractItem instances with "def items = ContractItem.findAllByCustomer(Customer.load(custo merId))". In this case I'm using the load() method to avoid an unnecessary database query for the Customer instance. If you've already loaded it for another reason (e.g. with get()) then just use that: ContractItem.findAllByCustomer(customer)

    Then add that to the model map that you're returning from the action

    [itemsByCustomer: items, ...]

    and loop through them like you were before:

    <g:each in="${itemsByCustomer}" status="i" var="contractItemInstance">

    p.s. You'll be better off asking questions on the User mailing list since there are a lot more users participating there. Sign up at


    • #3

      I'll sign up for the User mailing list ;-)