atom feed7 messages in org.codehaus.grails.userRe: [grails-user] Spring DSL : How to...
FromSent OnAttachments
Kapil SachdevaAug 15, 2009 2:23 pm 
Jeff BrownAug 15, 2009 3:30 pm 
Kapil SachdevaAug 15, 2009 4:29 pm 
Jeff BrownAug 15, 2009 5:27 pm 
Kapil SachdevaAug 15, 2009 5:36 pm 
Jeff BrownAug 17, 2009 6:04 am 
Kapil SachdevaAug 28, 2009 10:56 am 
Subject:Re: [grails-user] Spring DSL : How to pass ArrayList which takes references to other beans as a constructor argument
From:Kapil Sachdeva (ksac@gmail.com)
Date:Aug 15, 2009 5:36:08 pm
List:org.codehaus.grails.user

Thanks the util.list() is what I needed. Really appreciated your quick response

Regards & thanks again Kapil

On Sat, Aug 15, 2009 at 7:28 PM, Jeff Brown <je@jeffandbetsy.net> wrote:

On Sat, Aug 15, 2009 at 6:29 PM, Kapil Sachdeva<ksac@gmail.com> wrote:

public class SomeClass { public SomeClass(java.util.List<SomeOtherClass> soc) { } }

// grails-app/conf/resources.groovy beans = { someotherbean(com.example.SomeOtherClass, new File('somefile.txt')) somebean(com.example.SomeClass, someotherbean) }

As you can see that SomeClass accepts java.util.List as an argument. In the above example you are passing somebean(com.example.SomeClass, someotherbean)

as reference to someotherbean and not a list

The code that I showed you works. A List will be created and the bean will be added to the list. Another option you have is to create a list bean that is populated with the things you want in the list and pass that as a constructor argument. That could look something like this...

// grails-app/conf/resources.groovy beans = { xmlns util:"http://www.springframework.org/schema/util"

someotherbean(com.example.SomeOtherClass, new File('somefile.txt')) someotherbean2(com.example.SomeOtherClass, new File('somefile.txt'))

util.list(id: 'mybeans'){ ref(bean:'someotherbean') ref(bean:'someotherbean2') } somebean(com.example.SomeClass, ref('mybeans') ) }

Autism Strikes 1 in 166 Find The Cause ~ Find The Cure http://www.autismspeaks.org/