From: <ndi...@us...> - 2002-09-03 22:28:29
|
Update of /cvsroot/modus/org/bacfug/modus/fields In directory usw-pr-cvs1:/tmp/cvs-serv20374/bacfug/modus/fields Modified Files: basefield.cfc Log Message: cleaned up the CFFUNCTION attributes and fixed the newError() method to not improperly call the init() method on the fieldError twice. Index: basefield.cfc =================================================================== RCS file: /cvsroot/modus/org/bacfug/modus/fields/basefield.cfc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** basefield.cfc 3 Sep 2002 08:42:41 -0000 1.3 --- basefield.cfc 3 Sep 2002 22:28:24 -0000 1.4 *************** *** 1,5 **** <cfcomponent displayname="baseField" hint="The base component for a field"> <cfparam name="instance" default="#structNew()#"> ! <cffunction name="init" access="public" output="no"> <cfargument name="defaultValue" required="no" default=""> <cfscript> --- 1,5 ---- <cfcomponent displayname="baseField" hint="The base component for a field"> <cfparam name="instance" default="#structNew()#"> ! <cffunction name="init" access="public" output="no" returnType="org.bacfug.modus.fields.baseField" hint="initialize this instance, creating the instance variables"> <cfargument name="defaultValue" required="no" default=""> <cfscript> *************** *** 29,42 **** <!--- a way to set the label ---> ! <cffunction name="setLabel" access="public" output="no"> <cfargument name="label" required="yes"> <cfset instance.label = arguments.label> </cffunction> <!--- a way to get the label ---> ! <cffunction name="getLabel" access="public" output="no"> <cfreturn instance.label> </cffunction> <!--- a method for setting the value ---> ! <cffunction name="setValue" access="public" output="no"> <cfargument name="value" required="yes"> <cfscript> --- 29,42 ---- <!--- a way to set the label ---> ! <cffunction name="setLabel" access="public" output="no" returnType="void" hint="sets the value of the label"> <cfargument name="label" required="yes"> <cfset instance.label = arguments.label> </cffunction> <!--- a way to get the label ---> ! <cffunction name="getLabel" access="public" output="no" returnType="string" hint="get the value of the label"> <cfreturn instance.label> </cffunction> <!--- a method for setting the value ---> ! <cffunction name="setValue" access="public" output="no" returnType="void" hint="sets the value of the instance value -- also validates internally to set the error state"> <cfargument name="value" required="yes"> <cfscript> *************** *** 46,70 **** </cffunction> <!--- a method to get the type of CFC ---> ! <cffunction name="getType" access="public" output="no"> <cfreturn instance.metaData["NAME"]> </cffunction> <!--- a method to get the value ---> ! <cffunction name="getValue" access="public" output="no"> <cfreturn instance.value> </cffunction> <!--- a method to get the name ---> ! <cffunction name="getName" access="public" output="no"> <cfreturn instance.name> </cffunction> <!--- to render it by default, just spit it out ---> ! <cffunction name="toHTML" access="public" output="no"> <cfreturn toString(instance.value)> </cffunction> <!--- render a form field ---> ! <cffunction name="toFormField" access="public" output="no"> ! <cfreturn "<input type=""text"" name=""" & getName() & """ value=""" & htmlEditFormat(getValue()) & """>"> </cffunction> <!--- a method the package can use to set the attributes of this field with a short-hand ---> ! <cffunction name="setAttributes" access="public"<!--- access="package" --->> <cfargument name="attributesToAdd" required="yes" type="struct" output="no"> <!--- an iterator ---> --- 46,70 ---- </cffunction> <!--- a method to get the type of CFC ---> ! <cffunction name="getType" access="public" output="no" returnType="string" hint="get the type of field (based on the name key in the metaData"> <cfreturn instance.metaData["NAME"]> </cffunction> <!--- a method to get the value ---> ! <cffunction name="getValue" access="public" output="no" returnType="any" hint="get whatever the value of this instance is"> <cfreturn instance.value> </cffunction> <!--- a method to get the name ---> ! <cffunction name="getName" access="public" output="no" returnType="string" hint="get the name assigned to this instance"> <cfreturn instance.name> </cffunction> <!--- to render it by default, just spit it out ---> ! <cffunction name="toHTML" access="public" output="no" returnType="string" hint="renders the value to HTML."> <cfreturn toString(instance.value)> </cffunction> <!--- render a form field ---> ! <cffunction name="toFormField" access="public" output="no" returnType="string" hint="returns a simple text form widget. Typically overridden in any implementation of a field"> ! <cfreturn instance.formFieldFactory.makeText(getName(),getValue())> </cffunction> <!--- a method the package can use to set the attributes of this field with a short-hand ---> ! <cffunction name="setAttributes" access="public" returnType="void" output="no" hint="a convenience method. given a struct, sets private data members (instance variables) to the value in the struct, overriding any existing values."> <cfargument name="attributesToAdd" required="yes" type="struct" output="no"> <!--- an iterator ---> *************** *** 72,76 **** </cffunction> <!--- a method to validate ---> ! <cffunction name="validate" access="package" output="no"> <cfset var ruleArray = listToArray(instance.rules)> <cfset var ii = 1> --- 72,76 ---- </cffunction> <!--- a method to validate ---> ! <cffunction name="validate" access="package" output="no" returnType="void" hint="runs through any rules and sets the error state and adds any error messages necessary"> <cfset var ruleArray = listToArray(instance.rules)> <cfset var ii = 1> *************** *** 87,100 **** </cffunction> <!--- a method to get the errors ---> ! <cffunction name="getErrors" access="public" returntype="array" output="no"> <cfreturn instance.errors> </cffunction> <!--- a method to return a boolean to know if there are any errors ---> ! <cffunction name="hasErrors" access="public" returnType="boolean" output="no"> <cfreturn yesNoFormat(arrayLen(getErrors()))> </cffunction> <!--- a method to add an error ---> ! <cffunction name="addError" access="package" output="no"> ! <cfargument name="error" required="yes"> <cfscript> arrayAppend(instance.errors,arguments.error); --- 87,100 ---- </cffunction> <!--- a method to get the errors ---> ! <cffunction name="getErrors" access="public" returntype="array" output="no" hint="returns an array of fieldError objects"> <cfreturn instance.errors> </cffunction> <!--- a method to return a boolean to know if there are any errors ---> ! <cffunction name="hasErrors" access="public" returnType="boolean" output="no" hint="returns a boolean value for whether any errors exist for this instance"> <cfreturn yesNoFormat(arrayLen(getErrors()))> </cffunction> <!--- a method to add an error ---> ! <cffunction name="addError" access="package" output="no" hint="internal method to add an error to this instance"> ! <cfargument name="error" required="yes" type="org.bacfug.modus.errors.fieldError"> <cfscript> arrayAppend(instance.errors,arguments.error); *************** *** 102,110 **** </cffunction> <!--- a method to create an error ---> ! <cffunction name="newError" access="package" output="no"> <cfargument name="type" required="no" default="modus.field"> <cfargument name="message" required="no" default="A general error occurred in #instance.name#"> <cfargument name="detail" required="no" default="#arguments.message#"> ! <cfset var error = createObject("component","org.bacfug.modus.errors.fieldError").init()> <cfscript> error.init(arguments.message,arguments.type,arguments.detail); --- 102,110 ---- </cffunction> <!--- a method to create an error ---> ! <cffunction name="newError" access="package" output="no" returnType="org.bacfug.modus.errors.fieldError" hint="generates an error object, used primarily inside of addError()"> <cfargument name="type" required="no" default="modus.field"> <cfargument name="message" required="no" default="A general error occurred in #instance.name#"> <cfargument name="detail" required="no" default="#arguments.message#"> ! <cfset var error = createObject("component","org.bacfug.modus.errors.fieldError")> <cfscript> error.init(arguments.message,arguments.type,arguments.detail); |