Ticket #104 (closed enhancement: completed)

Opened 19 months ago

Last modified 4 months ago

Support initializing beans using <event-bean> that have other beans as members

Reported by: jason.blum@… Owned by: kurtwiersma
Priority: major Milestone: Mach-II 1.8.0 beta
Component: framework - core Version: 1.8.0 - Framework
Keywords: event-bean bean beans composition Cc: kurtwiersma, mattwoodward, brianfitzgerald, r.m.rogers@…
Blocking: Blocked By:

Description

Don't know if I've got my OOP terminology right, but the <event-bean> functionality is brilliant. But what if your form is updating fields corresponding to more than one bean, say a Person AND a Person.Supervisor (who, say, is also of type Person.)

Since your form fields can contain dots, would it be possible to, say, if the name of a form field is prefixed with the name of a member of the event-bean, go ahead and pass the event arg to the appropriate setters.

For example, am currently working on a form to update a person, and select that person's supervisor from a drop down list. So form passes the person's UUID and the UUID of a supervisor (who is also of type Person). I am currently using event-bean of person and manually adding the additional arg Person.Supervisor.uuid. But would be nice to just name those two fields uuid and supervisor.uuid.

Attachments

Change History

Changed 19 months ago by peterfarrell

  • keywords bean beans composition added
  • milestone set to Uncategorized

Jason, you are referring to beans that use composition (bean that is composed of other nested beans). This is definitely something we've thought about in the past and just never got the time to engineer it due to features like modules, includes, caching and logging. We'll try figure out a nice solution. I've thought about something like:

<event-handler event="myEvent" access="public">
   <event-bean name="person" type="path.to.Person">
      <inner-bean name="supervisor" prefix="supervisor" fields="uuid"/>
   </event-bean>
</event-handler>

Changed 16 months ago by peterfarrell

  • version changed from Uncategorized to 1.8.0
  • milestone changed from Uncategorized to Mach-II 1.8.0 alpha

Changed 14 months ago by peterfarrell

  • cc kurtwiersma, mattwoodward, brianfitzgerald added
  • priority changed from none to major
  • status changed from new to assigned
  • reporter changed from Jason Blum to jason.blum@…

FYI, we are going to add an enhancement similar to this in Mach-II 1.8 that will work in conjunction with the new form tag library with data binding. We have not realized the final implement yet, but will update this ticket as necessary.

Changed 13 months ago by peterfarrell

  • status changed from assigned to new
  • totalhours set to 0
  • hours set to 0
  • billable set to 1
  • owner changed from peterfarrell to mattwoodward
  • estimatedhours set to 0

Matt's going to take this one as well.

Just wanted to comment that we need to figure out way to engineer this for inner-beans get the same support for indicating the fields to be populated. Otherwise people could use this as a security hole to slip in data that wasn't on the form.

Also, we should figure out how to concatenate incoming fields (say a date that is broken up into month, day and year) into one field to populate the bean.

It could be something like:

<event-handler event="myEvent" access="public">
   <event-bean name="person" type="path.to.Person">
      <inner-bean name="supervisor" prefix="supervisor" fields="uuid">
         <field name="date" concatenate="${month}/${day}/${year}"/>
      </inner-bean>
   </event-bean>
</event-handler>

I don't know. Thinking how loud.

Changed 13 months ago by peterfarrell

BTW, the form tag lib uses dots to show the hierarchy of the fields. So in the example about we have a person bean with a supervisor in it. If you want the supervisor's first name the form tag lib would generate something like this:

<input name="supervisor.firstName" type="text" value="" />

The event-arg passed to the framework would be:

supervisor.firstName

Changed 12 months ago by devin@…

What about circular refences? I have a situation in that form data consists of fields for both an Account.cfc and Login.cfc, where there exists a bidirection one-to-one relationship between Account and Login.

Currently, with the event-bean syntax, I can set the relationship on side, but then I have to set the relationship on the other in a the Listener. Because of this, I end up creating both beans separately and setting both sides of the relathionship in the Listener to keep the relevant code together.

Changed 12 months ago by peterfarrell

@devin, There isn't anything that would stop you from doing what you current are doing as you would have to define the "inner" beans you want to populate via event bean as in the example code shows in a comments a couple above this one.

This is definitely something that we've already considered and I'm sure Matt will address as the feature is getting built.

Thanks for the comment -- great to have feedback from the user base.

Changed 9 months ago by peterfarrell

  • owner changed from mattwoodward to kurtwiersma

@Matt, Kurt is nearly done with his tickets (all cruft and little stuff) so it volunteered to take this ticket so you can focus on radioGroup and checkboxGroup tag this weekend.

Changed 8 months ago by kurtwiersma

(In [1685]) - Initial support for inner-beans with fields inside event-bean commands. refs #104

Changed 8 months ago by kurtwiersma

(In [1686]) - Initial test of support for inner-beans with fields inside event-bean commands. refs #104

Changed 7 months ago by peterfarrell

Kurt, could you please update the XML reference wiki entry with the syntax that you used for this? If you could include information on what you're planning to support as well.

Changed 7 months ago by kurtwiersma

I updated the Wiki with an example of using inner bean in its currently implemented form. After the beta release I may add some more automatic features as well as some type of expression and concatenation support.

Changed 5 months ago by kurtwiersma

  • status changed from new to assigned

Still need to add support for fields with concatenated expressions in them like the example below:

 <field name="date" concatenate="${month}/${day}/${year}"/>

Changed 5 months ago by peterfarrell

Kurt, Do we want to add in an concatenate attribute or just have the value attribute look for all expressions?

Changed 4 months ago by kurtwiersma

(In [1873]) - Added support for inner-beans to have other inner-beans - Added a new autopopulate attribute to event-bean command refs #104

Changed 4 months ago by kurtwiersma

(In [1874]) Testing out the reworked event-bean command. refs #104

Changed 4 months ago by kurtwiersma

(In [1877]) Added support for expression language resolved concatenated elements (example: "${event.day}/${event.month}/${event.year}") in a event-bean command field value. Also works with inner beans. refs #104

Changed 4 months ago by kurtwiersma

This feature should now be completely implemented. Leaving this ticket open until documentation is completed on this new feature. Mike Rogers has volunteered to help out with the documentation on this feature. Thanks Mike!

 http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/wiki/IntroductionToBeans

Changed 4 months ago by kurtwiersma

Ended up going with the standard value attribute for inserting concatenated expression.

<field name="date" value="${month}/${day}/${year}"/>

Changed 4 months ago by kurtwiersma

  • status changed from assigned to closed
  • resolution set to completed

Mike Rogers updated the documentation and I added the new autopopulate attribute to the page below.

 http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/wiki/ConfigFileExplained

Changed 4 months ago by peterfarrell

  • status changed from closed to reopened
  • resolution completed deleted

Kurt, the XML Config File Quick Reference and the Intro to Beans needs doco on the <field> for event-bean and inner-bean as well as an example of using the M2EL syntax to do concatenation of strings using the value attribute of the <field> tag. This is only a doco request.

Changed 4 months ago by peterfarrell

  • cc r.m.rogers@… added

Adding Mike to this ticket in case he experiments with the <field> tag of the event-bean or inner-bean as described in the previous comment regarding some doco updates.

Changed 4 months ago by kurtwiersma

  • status changed from reopened to closed
  • resolution set to completed

Add/Change #104 (Support initializing beans using <event-bean> that have other beans as members)

Author


E-mail address and user name can be saved in the Preferences.


Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.