Output of hasmany-Relation

R

ritedo

Guest
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!
 

dave

Administrator
Staff member
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>
 
Top