Hey Peter, thanks for the reply.

Wow, I can't believe that this works:

<notify listener="BillingListener" method="getInvoice"
resultArg="Invoice"/>
<event-arg name="guardianId" value="$
{event.Invoice.getGuardian().getId()}"/>

This is exactly what I wanted. I thought that M2 EL was too
restrictive to allow for what seems like arbitrary CFML, but this is
perfect. I had to comment it out and try it a few times for me to
believe that it actually was working.  So I'm really happy! I wonder
what other kludge I can remove from my apps with this...

Mach-ii rocks!

-Brian


On Apr 19, 2:23 am, "Peter J. Farrell" <[email protected]> wrote:
> A couple solutions come to mind:
>
> 1) Use event-args with M2 EL syntax:
>
> http://trac.mach-ii.com/machii/wiki/ConfigFileExplained#event-arg
>
> <event-arg name="userId" value="${event.userComment.userId:0}"/>
>
> 2) Use <call-method>
>
> http://trac.mach-ii.com/machii/wiki/MachII1.8CallMethodCommand
>
> <subroutine name="reportSnip">
>     <call-method bean="somethingService"
>         method="readBySomethingIdAndCompanyId"
>         args="${event.somethingId},${event.companyId}"
>         resultArg="something"/>
>     <call-method bean="adminService"
>         method="readAdmin"
>         args="${event.something.ownerAdminId},${event.something.companyId}"
>         resultArg="admin"/>
>     <call-method bean="locationService"
>         method="readLocation"
>         args="${event.something.locationId}"
>         resultArg="location"/>
>     <view-page name="snip_report" contentArg="layout.snip_report"/>
> </subroutine>
>
> 3) Use a filter.  I've been generic filters in the pass to work as data
> mappers.  Pulling a piece of data from complex nested objects into even
> args. Although, my suggestion with 1) using event arg with EL
> expressions works better these days.
>
> .pjf
>
> Brian H. said the following on 04/18/2011 11:54 PM:
>
>
>
>
>
>
>
>
>
> > Hey Guys.
>
> > It's common for events such as "viewUser" to have a listener notify
> > like:
>
> > <notify listener="UserListener" method="getUser" resultArg="User"/>
>
> > Where the listener expects a "userId" in the event. One problem that
> > I've yet to gracefully solve is when you have a event like
> > "viewUserComment". It expects a userCommentId in the event, but it
> > ALSO needs to pull the user using something like:
>
> > <notify listener="UserListener" method="getUser" resultArg="User"/>
>
> > Problem is that the userId is not in the event, it is nested in the
> > UserComment object. The solutions that I've discovered so far are:
>
> > 1. Create a new listener method "getUserFromUserCommentId" that uses
> > the "userCommentId" in the URL and pulls the associated User.
>
> > 2. Create a new listener method that exposes the userId in the event,
> > and then use the existing "getUser" method:
>
> > <notify listener="UserListener" method="getUserIdFromUserCommentID"
> > resultArg="userId"/>
> > <notify listener="UserListener" method="getUser" resultArg="User"/>
>
> > 3. Cause all links to "viewUserComment" to include UserCommentId AND a
> > UserId. Obviously this solution sucks.
>
> > Is anyone using any other method? In this example, assume that you
> > can't simply do a UserComment.getUser() to pull the User from the
> > comment.
>
> > -Brian
>
> --
> Peter J. Farrell
> [email protected]
> [email protected]http://blog.maestropublishing.com
> Identi.ca / Twitter: @maestrofjp

-- 
To post to this group, send email to [email protected]
For more options and to unsubscribe, visit this group at 
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en

SVN: http://svn.mach-ii.com/machii/
Wiki / Documentation / Tickets: http://trac.mach-ii.com/machii/

Reply via email to