
<mach-ii version="1.0">

  <!-- PROPERTIES -->
  <properties>
    <property name="defaultEvent" value="listContacts" />
    <property name="exceptionEvent" value="exception" />
    <property name="applicationRoot" value="/ows/38/mii_ContactMgr" />
    <property name="eventParameter" value="event" />
    <property name="parameterPrecedence" value="form" />
    <property name="maxEvents" value="10" />
  </properties>

  <!-- LISTENERS -->
  <listeners>
    <listener name="ContactManager" type="ows.38.mii_ContactMgr.model.ContactManager">
      <invoker type="MachII.framework.invokers.CFCInvoker_EventArgs" />
    </listener>
  </listeners>
  
  <!-- EVENT-FILTERS -->
  <event-filters>
    <event-filter name="eventArgs" type="MachII.filters.EventArgsFilter" />
    <event-filter name="requiredFields" type="MachII.filters.RequiredFieldsFilter" />
    <event-filter name="contactBeaner" type="ows.38.mii_ContactMgr.filters.ContactBeanerFilter" />
  </event-filters>

  <!-- EVENT-HANDLERS -->
  <event-handlers>
    
    <event-handler event="newContact" access="public">
      <!-- One way to set event-args... -->
      <event-arg name="submitEvent" value="createContact" />
      <event-arg name="submitLabel" value="Create" />
      <event-arg name="pageTitle" value="Create New Contact" />
      <event-arg name="cancelEvent" value="cancelCreateContact" />

      <announce event="showContactForm" copyEventArgs="true" />
    </event-handler>
    
    <event-handler event="editContact" access="public">
      <notify listener="ContactManager" method="getContact" resultKey="REQUEST.contact" />
      <!-- Second way to set event-args... -->
      <filter name="eventArgs">
        <parameter name="submitEvent" value="updateContact" />
        <parameter name="submitLabel" value="Update" />
        <parameter name="pageTitle" value="Modify Contact" />
        <parameter name="cancelEvent" value="cancelUpdateContact" />
      </filter>
      <announce event="showEditContactForm" copyEventArgs="true" />
    </event-handler>
  
    <event-handler event="showContactForm" access="public">
      <filter name="contactBeaner" />
      <view-page name="contactForm" contentKey="REQUEST.content" />
      <view-page name="mainTemplate" />
    </event-handler>
    
    <event-handler event="showEditContactForm" access="public">
      <filter name="contactBeaner" />
      <view-page name="editForm" contentKey="REQUEST.content" />
      <view-page name="mainTemplate" />
    </event-handler>
    
    <event-handler event="createContact" access="public">
      <filter name="requiredFields">
        <parameter name="requiredFields" value="lastname,userLogin,userPassword" />
        <parameter name="invalidEvent" value="newContact" />
      </filter>
      <notify listener="ContactManager" method="createContact" resultKey="REQUEST.createdContact" />
    </event-handler>
    
    <event-handler event="updateContact" access="public">
      <filter name="requiredFields">
        <parameter name="requiredFields" value="lastname,userLogin,userPassword" />
        <parameter name="invalidEvent" value="updateContact" />
      </filter>
      <notify listener="ContactManager" method="updateContact" resultKey="REQUEST.createdContact" />
    </event-handler>

    <event-handler event="promptDelete" access="public">
      <notify listener="ContactManager" method="getContact" resultKey="REQUEST.contact" />
      <view-page name="promptDelete" />
    </event-handler>

    <event-handler event="deleteContact" access="public">
      <notify listener="ContactManager" method="deleteContact" />
      <announce event="listContacts" />
    </event-handler>
    

    <event-handler event="contactCreated" access="private">
      <announce event="listContacts" />
    </event-handler>
    
    <event-handler event="contactUpdated" access="private">
      <announce event="listContacts" />
    </event-handler>
    
    <event-handler event="listContacts" access="public">
      <notify listener="ContactManager" method="getAllContacts" resultKey="REQUEST.allContacts" />
      <event-arg name="pageTitle" value="Contact List" />
      <view-page name="contactList" contentKey="REQUEST.content" />
      <view-page name="mainTemplate" />
    </event-handler>
    
    <event-handler event="viewContact" access="public">
      <notify listener="ContactManager" method="getContact" resultKey="REQUEST.contact" />
      <event-arg name="pageTitle" value="View Contact" />
      <view-page name="viewContact" contentKey="REQUEST.content" />
      <view-page name="mainTemplate" />
    </event-handler>
    
    <event-handler event="cancelUpdateContact" access="public">
      <announce event="listContacts" />
    </event-handler>
    
    <event-handler event="cancelCreateContact" access="public">
      <announce event="listContacts" />
    </event-handler>
    
    <event-handler event="exception" access="private">
      <view-page name="exception" contentKey="REQUEST.content" />
      <view-page name="mainTemplate" />
    </event-handler>
  </event-handlers>
  
  <!-- PAGE-VIEWS -->
  <page-views>
    <page-view name="mainTemplate" page="/views/mainTemplate.cfm" />
    <page-view name="editForm" page="/views/editForm.cfm" />
    <page-view name="promptDelete" page="/views/promptDelete.cfm" />
    <page-view name="contactList" page="/views/listContacts.cfm" />
    <page-view name="viewContact" page="/views/viewContact.cfm" />
    <page-view name="contactForm" page="/views/contactForm.cfm" />
    <page-view name="exception" page="/views/exception.cfm" />
  </page-views>
  
  <!-- PLUGINS -->
  <plugins>
  </plugins>

</mach-ii>
