porno porno rokettube
Results 1 to 2 of 2

Thread: Output of hasmany-Relation

  1. #1

    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
    package meinprojekt
    class Books {
    	String title
    	static hasMany = [readers : Person]
    	static belongsTo = [author : Person]
        static constraints = {
    and some part of my view:
    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
    West Yorkshire, UK - Valencia Spain
    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...

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

    Web & Mobile Development by Tucanoo Solutions Ltd


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.