inner-bean mechanics

2 views
Skip to first unread message

Mike Rogers

unread,
Oct 31, 2009, 3:21:15 PM10/31/09
to Mach-II for CFML
All,

I'm working in 1.8 BER with the new (as of two hours ago! Thanks,
Kurt!) recursive inner-bean handler. I've cleared my cache and
restarted ColdFusion, but I'm still having problems getting the inner-
most bean to get populated.

In my mach-ii.xml, I have an event-handler configured with the
following:

<event-bean name="user" type="@cf.app.root@.model.UserModel"
reinit="false"
fields="firstName,lastName,email,password">
<inner-bean name="organization" prefix="organization"
fields="name,sponsorCode,website">
<inner-bean name="address" prefix="address"
fields="lineOne,city,state,zip,phone,fax"/>
</inner-bean>
</event-bean>

And some samples using the 'form' custom tag:

<label for="firstName">First Name</label>
<form:input path="firstName"/>

<label for="website">Organization Website</label>
<form:input path="organization.website"/>

<label for="city">City</label>
<form:input path="organization.address.city"/>

And some output from the log:

Event-bean 'user' already in event. Repopulated with data.
Fields: 'firstName,lastName,email,password', Ignored Fields: ''
Inner-bean 'organization' with prefix 'organization' from event-
bean 'user' populated with data.
Listener 'UserListener' invoking method 'createAccountAction'.

It seems completely to skip the inner-most bean.

It's probably a configuration issue on my end. I could probably try
(and probably will try, if all else fails) Kurt's new
autopopulate="true" tag, but it will require rewriting a lot of Model
code.

Anyone have any suggestions?

Thanks,

-Mike Rogers

Kurt Wiersma

unread,
Oct 31, 2009, 4:24:10 PM10/31/09
to mach-ii-for...@googlegroups.com
Could be bug on my end. Try the same event-bean tag but add the
attribute autopopulate="true" and comment out all the stuff inside the
event-bean tag and see if that works.

I had to completely refactor the event-bean command so I am not
surprised we are discovering some potential issues.

--Kurt

Mike Rogers

unread,
Oct 31, 2009, 4:46:43 PM10/31/09
to mach-ii-for...@googlegroups.com
The autopopulate="true" attribute seems to disregard the
reinit="false" attribute I have set. The system tries to create an
object of type project.model.UserModel, which currently requires a
constructor. In order to test this route I will have to modify my
model objects to have their dependencies injected by mutator instead
of constructor-args.

Creating an object instance despite reinit="false"... is that a bug?
If it's not, I'll go ahead and switch up my model objects.

Let me know! Thanks!

-Mike Rogers

Kurt Wiersma

unread,
Oct 31, 2009, 5:02:33 PM10/31/09
to mach-ii-for...@googlegroups.com
I think what you are running into is that it needs to run createObject
in order to get the meta data about the component. I will create a new
MXUnit test case for your setup and see if I can fix the issue. Thanks
for trying it out.

--Kurt

Kurt Wiersma

unread,
Oct 31, 2009, 6:04:09 PM10/31/09
to mach-ii-for...@googlegroups.com
Turns out that autopopulate attribute was the only one I had working.
I have now committed support for defined multiple inner-beans in the
xml.

Give it a try and let me know what you think.

--Kurt

Mike Rogers

unread,
Oct 31, 2009, 8:23:03 PM10/31/09
to Mach-II for CFML
Kurt,

Everything works beautifully. Thanks for your help!

-Mike

On Oct 31, 6:04 pm, Kurt Wiersma <kwier...@gmail.com> wrote:
> Turns out that autopopulate attribute was the only one I had working.
> I have now committed support for defined multiple inner-beans in the
> xml.
>
> Give it a try and let me know what you think.
>
> --Kurt
>
>
>
> On Sat, Oct 31, 2009 at 4:02 PM, Kurt Wiersma <kwier...@gmail.com> wrote:
> > I think what you are running into is that it needs to run createObject
> > in order to get the meta data about the component. I will create a new
> > MXUnit test case for your setup and see if I can fix the issue. Thanks
> > for trying it out.
>
> > --Kurt
>
> > On Sat, Oct 31, 2009 at 3:46 PM, Mike Rogers <r.m.rog...@gmail.com> wrote:
>
> >> The autopopulate="true" attribute seems to disregard the
> >> reinit="false" attribute I have set. The system tries to create an
> >> object of type project.model.UserModel, which currently requires a
> >> constructor. In order to test this route I will have to modify my
> >> model objects to have their dependencies injected by mutator instead
> >> of constructor-args.
>
> >> Creating an object instance despite reinit="false"... is that a bug?
> >> If it's not, I'll go ahead and switch up my model objects.
>
> >> Let me know! Thanks!
>
> >> -Mike Rogers
>
> >> On Oct 31, 2009, at 4:24 PM, Kurt Wiersma wrote:
>
> >>> Could be bug on my end. Try the same event-bean tag but add the
> >>> attribute autopopulate="true" and comment out all the stuff inside the
> >>> event-bean tag and see if that works.
>
> >>> I had to completely refactor the event-bean command so I am not
> >>> surprised we are discovering some potential issues.
>
> >>> --Kurt
>
> >>> On Sat, Oct 31, 2009 at 2:21 PM, Mike Rogers <r.m.rog...@gmail.com>

Peter J. Farrell

unread,
Nov 1, 2009, 8:30:13 PM11/1/09
to mach-ii-for...@googlegroups.com
Mike Rogers said the following on 10/31/2009 07:23 PM:

> Everything works beautifully. Thanks for your help!
>
Thank you Mike! You're testing of the features (just hours after they
were committed) was invaluable in making Mach-II an even more awesome
tool for everybody.

I just wanted to mention that Mike has added documentation on the wiki
about using the new inner-bean command for event-bean on the wiki:

http://tinyurl.com/y9ucedl

With the addition of the form custom tag library
(http://tinyurl.com/co7otr) and the use of event-bean / inner-bean,
Mach-II now has complete around trip binding -- your forms are
auto-populated from your beans using a shortcut syntax and your deeply
nested beans auto-populated from your form posts. If you are not using
the event-bean command in your daily coding, you're missing out on an
awesome time-saver. So take 10 minutes to read our complete
documentation on these features so you can save yourself hours of coding
over a lifetime of your application. These additions to the framework
are yet another way for you to get more done at work quicker and so you
can go home sooner.

Best,
.Peter
Team Mach-II

P.s. And if you have any questions, pipe up on the list here -- I'm sure
somebody from Team Mach-II or our unofficial inner-bean master -- Mike
Rogers can help you out!

Reply all
Reply to author
Forward
0 new messages