Redirect in Model-Glue

152 views Asked by At

There is this app we are running in parallel prior to moving it from external server to our internal servers. It is a two part application: the public/unsecured part (directory A) and the secured part (directory B). It's all wired up in Model-Glue/Coldspring.

As part of the User Registration process, there is a redirect from Directory A to B. This however, is generating an error: "Model-Glue: There is no known event handler for '/path/to/Direcory B/x.cfm'."

Here is the ModelGlue snippet:

<event-handler name="do.emailUser">
    <broadcasts>
        <message name="emailRegisterAction" />
    </broadcasts>
    <results>
        <result do="/path/to/directory B/x.cfm" redirect="true" />
    </results>
    <views />
</event-handler>

I have tried copying the shared file to Directory A, but that isn't a DRY solution, and seems like a hack. Perhaps, I should point out that the code works in Production on external servers, but fails in our development environment.

Any help will be appreciated. Thanks

1

There are 1 answers

0
rrk On BEST ANSWER

An old thread, may be it will help someone in future.

Things to remember.

<result> expects three attributes.

  1. name :Supposed to be the result name which you set from your controller.
  2. do : The event which needs to executed when the result with this name is created.
  3. redirect : Condition saying whether to redirect or not to.

So based on these conditions. Ideally your <event-handler> should look something like this.

<event-handler name="do.emailUser">
    <broadcasts>
        <message name="emailRegisterAction" />
    </broadcasts>
    <results>
        <result name="goToX" do="do.eventToXFile" redirect="true" />
    </results>
    <views />
</event-handler>
<event-handler name="do.eventToXFile">
    <broadcasts>
        <message name="yourMessageListner" />
    </broadcasts>
    <results>
        <result do="view.template" />
    </results>
    <views>
        <include name="body" template="/path/to/directory B/x.cfm" />
    </views>
</event-handler>

Once you set <cfset arguments.event.addResult("goToX")> in the emailRegisterAction function, then the page will redirect to the do.eventToXFile event, which in turn executes x.cfm.