Ask a Question related to Coldfusion Flash Integration, Design and Development.
-
FlashHack #1
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.
FlashHack Guest
-
cfform giving errors
Hello, I don't mean to sound desperate but I am. I'm trying to get the cfform to work but it give me an error saying that I used attributes wrong,... -
ASP Command Object Syntax Errors
I'm having difficulty using a straight-forward ASP/VBScript Command Object generated by DMX04. The code is supposed to insert into a SQL Server 2000... -
VB runtime errors "ActiveX can't create object"
How is the VB component compiled? Using 'unattended execution'? -- compatible web farm Session replacement for Asp and Asp.Net... -
supress errors at the page level? Undefined index errors.
I'm creating a simple reply form, and if a form item isn't answered I get an error: "Notice: Undefined index: rb_amntspent in... -
Best way to approach object construction errors?
I've created a class called university, it has a constructor which can accept an id. If the id is sent during construction the constructor will... -
-==cfSearching==- #2
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.
[url]http://www.asfusion.com/blog/entry/enabling-and-disabling-validation-in[/url]
[url]http://livedocs.adobe.com/flex/15/asdocs_en/mx/validators/Validator.html[/url]
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>
-==cfSearching==- Guest
-
FlashHack #3
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!
FlashHack Guest
-
-==cfSearching==- #4
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
[url]http://www.coldfusionusers.com/blog/index.php/2006/07/[/url]. 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();
}
-==cfSearching==- Guest
-
FlashHack #5
Re: CFFORM errors object?
Excellent! Thanks again. You are a gentleperson and a scholar.
FlashHack Guest



Reply With Quote

