Filter problem?

7 views
Skip to first unread message

Joe Bodell

unread,
Sep 6, 2011, 3:47:22 PM9/6/11
to mach-ii-for...@googlegroups.com
I feel confident that we're just doing something wrong, but here's what's going on anyway.

What we're trying to do is this: http://trac.mach-ii.com/machii/wiki/FAQDynamicallyDisplayViewInFilter

Essentially, if some conditions pass, display a view component, then continue on with the rest of the view (footers, etc). Event handler:

        <event-handler event="thresholdRequest.details" access="public">
            {some event args}
           
            <notify listener="thresholdRequestListener" method="getRequestInfo" resultArg="qryGetRequestInfo" />

            <view-page name="header" />
            <view-page name="pageTitle" />
            <view-page name="thresholdApprove" />
           
            <filter name="approvalFormFilter">
                <parameter name="RMView" value="showApproveRM" />
                <parameter name="DFAView" value="showApproveDFA" />
            </filter>
           
            <view-page name="pageFooter" />
            <view-page name="footer" />
        </event-handler>

And here's the text of the filterEvent() method (hints redacted):

    <cffunction name="filterEvent" access="public" returntype="boolean" output="true">
        <cfargument name="event" type="MachII.framework.Event" required="true" />
        <cfargument name="eventContext" type="MachII.framework.EventContext" required="true"  />
        <cfargument name="paramArgs" type="struct" required="false" default="#structNew()#" />       
       
        <cfif {some conditions}>
            <cfset arguments.eventContext.displayView(event = arguments.event, viewName = arguments.paramArgs["RMView"]) />
        <cfelseif {some other conditions}>
            <cfset arguments.eventContext.displayView(event = arguments.event, viewName = arguments.paramArgs["DFAView"]) />
        </cfif>
       
        <cfreturn true />
    </cffunction>

What I expect to have happen if {some conditions} or {some other conditions} add up to true is that either RMView or DFAView is displayed, and then the pageFooter and Footer views are displayed afterward. If {some conditions} and {some other conditions} return false, then we'd just see pageFooter and Footer. However, what we're observing is that when one of those conditions is true, the optional view component is displayed and then the event stops processing -- pageFooter and Footer are not touched.

Are we doing something wrong here?

Thanks,

Joe

Peter Farrell

unread,
Sep 6, 2011, 4:17:16 PM9/6/11
to mach-ii-for...@googlegroups.com

First, turn on MachII logging to check that your event is running the way you want.  The MachIILogger is unbelieveably helpful in this case.

Secondly, we manage a lot of cfsetting enablecfoutputonly inside of MachII and that can easily be messed up.  No MachII application needs to set any enablecfoutputonly's as of 1.8 since we spend probably 20 hours getting that all nipped and tucked in the right places.

My guess is both of the views in your filters probably have enablecfoutputonly in cfsettings in them.  Have you tried a simple view with only a simple h1 - I did it - in it?

> --
> To post to this group, send email to mach-ii-for...@googlegroups.com
> 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/

Joe Bodell

unread,
Sep 6, 2011, 4:21:43 PM9/6/11
to mach-ii-for...@googlegroups.com
I'll give the logging a shot, and get back to you. However, I don't think the enablecfoutputonly is the issue.... here's the content of one of the views (the other is very similar):

<cfoutput>
    <form action="?event=#event.getArg('xe.formTarget')#" method="post" class="threshholdForm">
        <input input type="hidden" name="REQ_ID" value="#Trim(event.getArg('REQ_ID'))#">
        <input input type="hidden" name="LEVEL" value="2">
       
        <div>
            <label for="decision">DFA Decision:</label>
            <input type="radio" name="DECISION" value="Approve" /> Approve
            <input type="radio" name="DECISION" value="Deny" /> Deny
           
        </div>
       
        <div>
            <label for="first_approval">DFA Comments:</label>
            <textarea name="DECISION_COMMENTS" id="first_approval">#Trim(event.getArg('DECISION_COMMENTS'))#</textarea>
        </div>
        <div>
            <input type="submit" value="Submit" class="button"/>
        </div>
    </form>
</cfoutput>

Curiously, before I sent my question I tried doing a simple <cfinclude> on the view template inside filterEvent() and it behaved as expected (footer views included after the filter "true" case)

I'll let you know what happens in the logs.
--
------------------------
Joe Bodell
joe.b...@gmail.com
(c) 952-465-5096

Joe Bodell

unread,
Sep 7, 2011, 11:51:14 AM9/7/11
to mach-ii-for...@googlegroups.com
Well, I turned on logging, and confirmed that the views *are* being rendered. I then realized what the problem was: since enablecfoutputonly was set to true, the content in the views was missing because they didn't contain <cfoutput> tags around their content!

In any case, still very helpful to get the machiilogger up and running. Thanks PJF

--Joe

Joe Bodell

unread,
Sep 7, 2011, 2:18:14 PM9/7/11
to mach-ii-for...@googlegroups.com
Sorry to be the "reply-to-self-again-and-again" guy...but we're seeing some funny behavior. We have views (detailed above) which are used in events that don't use the filter call. These views (before I fixed this issue) weren't wrapped in <cfoutput>s -- but in events that do NOT use a filter before rendering these views, their content appears just fine. When the views are called *after* the filter call, that's when enablecfoutputonly appears to apply correctly and nix content that's not inside a <cfoutput>.

Obviously the "right" way to do this is to have <cfoutput>{content}</cfoutput> in every view, but still -- why was the content outside the cfoutputs rendering properly before the filter method is called?

I'm sure there's still something I'm missing...
Reply all
Reply to author
Forward
0 new messages