<cftset variables.comment = application.libUtil.ConvertToHTML(
arguments.comment );

Not a great idea. You'll see this if you want to unit test it and you have to 
put stuff into the Application scope.

If you use a factory like Lightwire or Coldspring or one of your own then when 
you ask the factory for a bean, give the bean your object that does the 
conversion.

If you don't want to get as complicated then your beans could extend a base 
bean that has the method. Problem with this though is if anything other than 
beans needs the method you need to refactor it out of the base bean and use 
composition/aggregation (can never choose between them :-) instead.

I have this sort of stuff in a method object called StringMethods.cfc but you 
can put it where you like really.

Alan
________________________________________
From: [email protected] [EMAIL PROTECTED] On Behalf Of Ronan Lucio [EMAIL 
PROTECTED]
Sent: 02 July 2008 21:40
To: [email protected]
Subject: [CFCDEV] Re: Security checks

Peter Bell escreveu:
> I'd have some kind of validate method on the bean. Probably use it to
> call a composed validation bean. I'd put the logic there.

Good suggestion, the validation could be in the set() methods

<cffunction name="setComment">
    <cfarguments name="comment" type="string" required="true" />

    <cfset variables.comment = application.libUtil.ConvertToHTML(
arguments.comment );

</cffunction>


<cffunction name="setURL">
    <cfarguments name="stringURL" type="string" required="true" />

    <cfif Left(arguments.stringURL, 4) neq "http">
       <cfset variables.stringURL = "http://"; & arguments.stringURL />
    <cfelse>
       <cfset variables.stringURL = arguments.stringURL />
    </cfif>

</cffunction>

Thanks,
Ronan



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
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/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to