porno porno rokettube
Results 1 to 2 of 2

Thread: Output of hasmany-Relation

  1. #1
    Junior Member
    Join Date
    Jan 2015
    Posts
    2

    Output of hasmany-Relation

    Hi there,
    I'm working on a view, that shows a hasmany-relationship (it's just an example):

    domain Books.groovy
    Code:
    package meinprojekt
    
    class Books {
    	String title
    	
    	static hasMany = [readers : Person]
    	static belongsTo = [author : Person]
    	
    	
        static constraints = {
        }
    }
    and some part of my view:
    Code:
    <td>${booksInstance.readers}</td>
    the output works, it looks like:
    [Peter, Thomas, Susan, Jenny]

    My question: is there any way just to show the names without the brackets?

    Thank you in advance!

  2. #2
    Administrator dave's Avatar
    Join Date
    Mar 2010
    Location
    West Yorkshire, UK - Valencia Spain
    Posts
    110
    You're seeing the brackets because you're seeing a toString() representation of a Collection.

    If you still wanted comma seperation then I would use the java method join() to return a single String representation of the individual collection elements joined by a command and space.

    So your output would be...

    Code:
    <td>${booksInstance.readers?.join(', ')}</td>
    Connect with me on twitter : @davebrown1975 http://twitter.com/davebrown1975

    Web & Mobile Development by Tucanoo Solutions Ltd

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Forum Design by Tucanoo Solutions Ltd Grails Development Specialists.