This is really a ColdSpring question rather than a Model-Glue question,
so the coldspring-users Google group is a better place for it. I'll
offer my thoughts here but I urge you to post any followups to the
coldspring-users group. I am a member of both groups so you won't have
to Cc me.

A couple of things struck me with your example that might (or might not)
be related to your problem.

I don't like your choice of "objCollection" for the ID of the bean you
use for the phone collection. It may become tempting to reference that
bean anywhere a generic collection is needed, however since it's a
singleton ColdSpring will use the same instance in each place. You could
end up with one collection instance that serves as a phone collection
for one bean and as an address collection for another bean. To avoid
that kind of problem, I recommend a bean ID like "phoneCollection" instead.

In your init() method, the PhoneCollection argument is not required but
has a default of "". When using type="any" for bean arguments you should
not use default values that are not valid beans as it can make problems
like these harder to trace. I recommend making the argument required: if
you get an error after doing that then you may have a bigger problem in
more urgent need of fixing.

Cheers,

Dennis


On 4/9/2009 1:51 AM, Revolution Wines wrote:
> Hello,
>
> I am working on my first MG project and am still not quite getting how
> to hard wire objects in the Coldspring XML. Right when I think I'm
> starting to get it, I come across some unanticipated hick-ups.
>
> So, I have a PersonFormBean object and I'm trying to add a collection
> of phone numbers for a person...a one to many thing.
>
> I have a personFormBean and this bean requires a generic collection
> container:
>
> <bean id="ObjCollection" class="logon.model.ObjCollection" />
>
> This cfc has generic methods such as "add", "getAt", "removeAt".  So,
> I want to add a phone numbers collection to the PersonFormBean:
>
>       <bean id="PersonFormBean" class="logon.model.PersonFormBean" >
>         <constructor-arg name="PhoneCollection"><ref  bean="ObjCollection" /
>   
>> </constructor-arg>
>>     
>       </bean>
>
> For good measure I have a PhoneFormBean as well:
>
> <bean id="PhoneFormBean" class="logon.model.PhoneFormBean" />
>
> The PersonFormBean init method has constructors for the
> PhoneCollection:
>
> <cffunction name="init" access="public"
> returntype="logon.model.PersonFormBean" output="false">
>
> ...
>
> <cfargument name="PhoneCollection" type="any" required="false"
> default="" />
>
> ...
> <cfset setPhoneCollection(arguments.PhoneCollection) />
>
>
> </cffunction>
>
>
>       <cffunction name="setPhoneCollection" access="public"
> returntype="void" output="false">
>               <cfargument name="PhoneCollection" type="any" required="yes">
>               <cfset variables.instance.PhoneCollection =
> arguments.PhoneCollection>
>       </cffunction>
>
>       <cffunction name="getPhoneCollection" returntype="any"
> output="false">
>               <cfreturn variables.instance.PhoneCollection>
>       </cffunction>
>
>
> So, the problem is that none of the methods of PhoneCollection are
> accessible.  As a sanity check I commented out all the init lines
> above and added the following to the init() method in PersonFormBean:
>
> <cfset variables.instance.Phonecollection = createobject
> ("component","logon.model.objCollection")>
>
> Once I added this, then everything started working properly through
> the rest of my app.  Clearly, something is not wired up correctly in
> the Coldspring.xml....
>
> Any thoughts?
>
> Joe
>
>
> >
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to