Adobe Dreamweaver Forums



Last 10 THreads :         ZEND STUDIO ! does it work on any php capable server orneed some sepcialized? (Last Post : LuigiL - Replies : 1 - Views : 2 )           »          move tab with embedded image (Last Post : VPI MkIII - Replies : 3 - Views : 4 )           »          Importing an existing website? (Last Post : MarkV84 - Replies : 2 - Views : 3 )           »          Inserting XSL fragments (Last Post : whatisgood - Replies : 0 - Views : 1 )           »          How to upload JPEG files using ActionScript 3.0 (Last Post : Srihari.Ch - Replies : 0 - Views : 1 )           »          How to upload JPEG files using ActionScript 3.0 (Last Post : Srihari.Ch - Replies : 0 - Views : 1 )           »          Paste inside & opacity (Last Post : sniffer2209 - Replies : 2 - Views : 3 )           »          Help with new user (Last Post : geojf3 - Replies : 4 - Views : 5 )           »          Mail Sending status  (Last Post : Daverms - Replies : 2 - Views : 3 )           »          Fireworks pop-up menu (Last Post : Primal69 - Replies : 2 - Views : 3 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Cold Fusion > Flash Intergration
 
Tags:



Reply
  #1 (permalink)  
Old 11-06-2008, 09:43 PM
FlashHack
 
Posts: n/a
Diggs:
Default CFFORM errors object?

The CFFORM documentation mentions an "errors" object that can be accessed via
actionscript in Flash format. I can't get the sample code in the docs to work.
Has anyone successfully accessed this object? Can you give me some more
detail regarding it's structure and use? BOTTOM LINE: I would like to run some
actionscript in the onSubmit event that would test for the existence of
validation errors before running a flash remoting call.



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-09-2008, 05:54 PM
-==cfSearching==-
 
Posts: n/a
Diggs:
Default Re: CFFORM errors object?

The older entries at asfusion.com are a very good resource for all things
cfform/flash related. The Flex documentation is also useful.

http://www.asfusion.com/blog/entry/e...-validation-in
http://livedocs.adobe.com/flex/15/as...Validator.html

I do not do much work with cfform/flash. But here is a small example
demonstrating the onError method. It is not meant to do anything but show the
error object properties. As it uses cfformitem type="script" it requires MX
7.02+ (IIRC).





<!--- onError example --->
<cfform name="form1" format="flash" onError="doOnError(errors);" width="500"
height="300">

<cfformitem type="script">
function doOnError(errors:Object):Void {
var msg:String = "";

// for each error
for (var key in errors) {
// retrieve current error object
var err = errors[key];
// display error object properties
msg += "NAME ="+ err['name'] +"\n";
msg += "FIELD ="+ err['field'] +"\n";
msg += "VALUE ="+ err['value'] +"\n";
msg += "MESSAGE ="+ err['message'] +"\n\n";
}

alert("Inside doOnError function\n\n"+ msg);
}
</cfformitem>
<cfformgroup type="horizontal">
<cfinput type="text" name="firstname" label="First Name:" value=""
required="true" validateat="onSubmit" validate="noblanks">
<cfinput type="text" name="lastname" label="Last Name:" value=""
required="true" validateat="onSubmit" validate="noblanks">
<cfinput type="submit" label="Submit Form" name="submitButton" value="Submit
Form">
</cfformgroup>
</cfform>

<!--- onSubmit --->
<cfform name="yourFormName" format="flash" width="500" height="300"
onSubmit="return doSomethingOnSubmit();">

<cfformitem type="script">
function doSomethingOnSubmit() {
// check for one or more errors
var isFormValid = mx.validators.Validator.isStructureValid(this,
'yourFormName');

// if no errors found
if ( isFormValid ) {
// do whatever code here
}
else {
alert("Inside doSomethingOnSubmit function:\n Errors found. Do something
here.");
}

// if true, the form will be submitted.
return isFormValid;
}
</cfformitem>
<cfformgroup type="horizontal">
<cfinput type="text" name="firstname" label="First Name:" value=""
required="true" validateat="onSubmit" validate="noblanks">
<cfinput type="submit" label="Submit Form" name="submitButton" value="Submit
Form">
</cfformgroup>
</cfform>

Reply With Quote
  #3 (permalink)  
Old 11-10-2008, 07:54 PM
FlashHack
 
Posts: n/a
Diggs:
Default Re: CFFORM errors object?

Thank you, mysterious stranger who roves the forums seeking programmers in
distress! That certainly helps me get half-way there.

What I would like to do is "submit" the form using a flash remoting call
attached to a button's onClick event. With the "isStructureValid" method you
have shown me, I am able to stop the remoting call if there are errors (half my
problem), but I am not sure how to produce an alert listing all the error
messages. CFFORM produces this alert automatically if you actually submit the
form, but I am not really submitting it. Is there a way to access this
collection or errors outside of the onError method (which only seems to fire if
you submit the form via the traditional method)? Thanks!

Reply With Quote


  #4 (permalink)  
Old 11-10-2008, 09:54 PM
-==cfSearching==-
 
Posts: n/a
Diggs:
Default Re: CFFORM errors object?

The are tons of comments in the asfusion link above, but check the one by Laura
(dated August 22, 2005 at 9:28 PM). She mentions: "If you want to completely
emulate the way cfform does it by default, call userOnError() (although it is
one of those hacks that may change in the future)"
.

You can view the userOnError function code, by
http://www.coldfusionusers.com/blog/index.php/2006/07/. It uses
CFFormValidators.getInValidFields() to retrieve the error structure and display
them in a pop-up. I do not how much of that is documented. But at least it
gives you an idea how CF handles it.


function userOnError(){
var errors = CFFormValidators.getInValidFields();
var msg = "<ul>";
for(var key in errors )
{
msg += "<li>" +errors[key]['message'] +"</li>";
}
msg += "<ul>"
errorpopup = mx.managers.PopUpManager.createPopUp(this,
FormErrorException, true, {message: msg}, true);
errorpopup.centerPopUp(this);
errorpopup.setFocus();
}

Reply With Quote
  #5 (permalink)  
Old 11-10-2008, 10:34 PM
FlashHack
 
Posts: n/a
Diggs:
Default Re: CFFORM errors object?

Excellent! Thanks again. You are a gentleperson and a scholar.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 01:48 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk