Hi,
This may sound a stupid question, but we are trying to figure out a
way to instantiate the resource bundle inside a class (component) in
our model.
We are creating a class to validate the forms and there is a method in
this class that returns the error messages that will be processed in
the handler. It's working fine, but now we need to have this class
calling the resource bundle in order to properly get the message in
the resource bundle, before sending to the handler.
He have the following method in the validation class:
<cffunction name="init" returntype="void" output="false"
displayname="Init" hint="Form Validation Constructor" >
<cfset This.valid = true>
<cfset This.errorMessages = ArrayNew(1)>
<!--- ISSUE IS HERE --->
<cfset This.resources = CreateObject
("component","coldbox.system.plugins.resourceBundle")>
</cffunction>
<cffunction name="isRequired" access="public" output="false"
returntype="void" displayname="Required Field" hint="Check if the
value of required field is not blank">
<cfargument name="name" type="string" required="true"
displayname="Name" hint="Name of the field to be validated">
<cfargument name="value" type="string" required="true"
displayname="Value" hint="Value of the field to be validated">
<cfif trim(Arguments.value) eq "">
<cfset This.valid = false>
<cfset ArrayAppend(This.errorMessages,Arguments.name &
This.resources.getResource("manageLanguages.create")) /
</cfif>
</cffunction>
How can we achieve such thing using the framework / best practices ?
This class does extends any other class from the framework.
Thank you very much!
Julio Lima