I've looked through multiple sample apps... Contact manager,
AppBooster, Roulette and not finding any that do error handling.  This
thread deals with where to put code but I'd like to find a sample of
how to handle error messages from a form submit.  For some reason it
it either disguised or not done in the samples I've looked at so far.
Were the examples simplified and omit this detail or is it handled and
i'm not seeing it?

You like more details about my situation here's a question about one
situation.
I have a form that is used to upload a file to the server if it's not
there already or select from a list of files already on the server.
The next event will be to then display a record of details about that
document.  The upload form displays a list of documents in the
destination folder first, with a radio button beside each so that any
can be selected. Below that is a Select button. Then the form displays
a file browser and field that the browser will populate followed by an
Upload button. The instructions state something like...  "if you don't
find the file on the server, then upload it here."  Regardless if they
select a file or upload a file both result in taking them to the
document record form next for editing the details about the document.

So my form has too submit buttons. I need to detect which one is
clicked and handle accordingly.  How do I do this in the listener? or
in the event-handler?

My event-handlers are:
                <event-handler event="editDoc" access="public">
                        <event-arg name="pageTitle" VALUE="Document Details 
Form" />
                        <event-arg name="jsFile" 
value="/views/documents/documents.js" />
                        <notify listener="documentListener" 
method="getDocumentDetails"
resultArg="documentBean" />
                        <notify listener="documentListener" 
method="getDocumentTypes"
resultArg="qDocTypes" />
                        <notify listener="documentListener" 
method="getLicenseTypes"
resultArg="qLicenseTypes" />
                        <notify listener="documentListener" 
method="getContentOwners"
resultArg="qContentOwners" />
                        <view-page name="showDocumentDetails" 
contentarg="content" />
                        <view-page name="mainTemplate" />
                </event-handler>

                <event-handler event="uploadDoc" access="public">
                        <event-arg name="pageTitle" VALUE="Document Upload 
Form" />
                        <event-arg name="documentDir" VALUE="new" />
                        <notify listener="documentListener" 
method="getDocsDirList"
resultArg="qDocsListing" />
                        <view-page name="showUploadDocument" 
contentarg="content" />
                        <view-page name="mainTemplate" />
                </event-handler>

                <event-handler event="processUploadDoc" access="private">
                        <notify listener="documentListener" 
method="uploadDocument" />
                        <announce event="editDoc" />
                </event-handler>

                <event-handler event="processSelectDoc" access="private">
                        <notify listener="documentListener" 
method="selectDocument" />
                        <announce event="editDoc" />
                </event-handler>

First displays the upload form. The second is what I plan for the
processing the Upload button click. Not sure how to direct to the
events here. Not sure how to make the Select button click go to
processSelectDoc event above for handling the document bean load.
Will the bean be visible from  the next form for viewing the document
record... the editDoc event?  Do I let the bean load in that event
deal with loading the bean I just load the event obj with the doc ID
in the space below where it says "---get document bean code goes
here---"?

My uploadDocument method in the documentListener is (it's not
completed or debugged, based heavily on what Adam proposed... how does
it look?):

        <cffunction name="uploadDocument" output="false" access="public"
returntype="boolean" hint="returns true when a document successfully
uploaded to the server">
                <cfargument name="event" type="MachII.framework.Event"
required="true" />

                <cfscript>
                var validator = CreateObejct
("component","model.documentValidator").init( DSN = getProperty
("dsn"), event.getArgs() );

                validator.getUploadErrors();

                if( validator.isValid() ) {
                  try {
                        //---get document bean code goes here---
                        announceEvent("success");
                  } catch( ValidationError error ) {
                        event.setArg("arrDatabaseErrors",[error.message]);
                        announceEvent("databaseFailure");
                  }
                } else {

                  
event.setArg("arrValidationErrors",validator.getUploadErrors());
                  announceEvent("validationFailure");

                }
                </cfscript>

                <cfreturn documentGateway.uploadDocument(event) />
        </cffunction>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to Mach-II for CFML list.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/mach-ii-for-coldfusion?hl=en
SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
Wiki / Documentation / Tickets: 
http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/
-~----------~----~----~----~------~----~------~--~---

Reply via email to