This is off the top of my head so do not trust it 100%
<cfscript>
objBlah = CreateObject("component", "Blah").Init();
objBlah.ValidateStuff(FORM);
if(objBlah.GetValidated() IS false) {
WriteOutput(objBlah.GetValidatedMsg());
}
else {
objFoo = CreateObject("component", "Foo").Init();
objFoo.InsertMyStuff(FORM);
}
</cfscript>
So you instantiate the object, within that you have a method named
ValidateStuff and that method requires a structure to be passed in for its
one argument. It does whatever your validation is over that structure and
if any of it fails then within the object it appends to a
Variables.ValidatedMsg and it sets a Variables.Validated flag to false.
Then you have two other methods and they simply return those Variables from
within the CFC. One of those Variables is just a boolean flag to tell you
if validation passed or failed and the other has the failing message.
On Mon, Oct 20, 2008 at 9:40 AM, Rick Faircloth <[EMAIL PROTECTED]>wrote:
> Can you show me an example of using a CFC function to return error
> results/messages
> to the calling page?
>
> When an invoked CFC is called into play, is the data it produces
> available to
> the calling page as in a cfinclude?
>
> Rick
>
> Aaron Rouse wrote:
> > I do something similar to this in one of my projects. I have the
> validation
> > rules more or less in my beans then I have a validator CFC that will
> check
> > a bean to validate things. If validation passes it proceeds to the
> > insert/update and if it fails it returns the reasons so they can be
> > displayed to the user for corrective purposes.
> >
> > On Mon, Oct 20, 2008 at 1:39 AM, Mike Kear <[EMAIL PROTECTED]>
> wrote:
> >
> >
> >> If you ar using the techniques outlined in my cfc tutorials, Rick, i
> >> can easily give you the additional part - validation ..
> >>
> >> I was getting around to writing part 3 eventually mabye i'll just
> >> run it forward .
> >>
> >> IN the methods i use, each bean contains its own validation methods
> >> and you run a validation procedure just before the Save. IF the bean
> >> validates teh save proceeds, if it doesnt, error messages are posted
> >> either to the form or in an email to the person concerned with that
> >> app.
> >>
> >> Cheers
> >> Mike Kear
> >>
> >>
> >> On Mon, Oct 20, 2008 at 2:09 PM, Rick Faircloth
> >> <[EMAIL PROTECTED]> wrote:
> >>
> >>> Hi, all...
> >>>
> >>> I'm slowly but surely integrating CFC's into my coding.
> >>>
> >>> But now I'm wondering how best to modify my usual CF validation
> >>> of form values with a CFC in the mix.
> >>>
> >>> I typically design a page with a form, have it submit back to itself,
> >>> run validation on the form variables, output appropriate error messages
> >>> if needed,
> >>> and if everything validates, I run the query, let's say an insert
> query,
> >>> on the
> >>> same page as the form, then using cflocation to direct to a success
> page.
> >>>
> >>> But, using the CFC requires that the form's action page be the cfc
> >>>
> >> itself,
> >>
> >>> with the method in the URL, e.g., "properties.cfc?method=insert"
> >>>
> >>> Will I end up having to use session variables to make this work so I
> can
> >>> submit the form back to the page it's on, validate and if all
> validates,
> >>> then
> >>> change the form variables to session variables and using cflocation to
> >>> then go to the cfc? Can that even be done?... cflocation
> >>> url="properties.cfc?method=insert" ???
> >>>
> >>> Thanks for any feedback.
> >>>
> >>> Rick
> >>>
> >>>
> >>>
> >>
> >
> >
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314141
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4