The more I venture into OO type of design the more I have to get my head around
todays its "getters and setters". I think I am 'getting' in to the swing of
this but I could do with some advice please! any advice and help is welcome!
I have no idea if I am just making this up as I go along anymore lol!
I have a ColdBox application which I am trying to learn ColdSpring with, so I
have ColdSpring setup I need to it use...here how it went
I wanted to do some basic validation on a form and check if the user exists in
the DB.
Below is my code, from my understanding. Right or wrong?
var rc = event.getCollection();//RC Reference
var userBean = variables.adminUsersService.createAdminUserBean(); //Create
adminUserBean
var errors = userBean.validateUser(rc);//Check For Validation Errors
if (NOT ArrayLen(errors)){//No Validation Errors
getPlugin('beanFactory').populateBean(userBean);
resultCount = variables.adminUsersService.validateCredentials(userBean);
//Check Login Credentials Does User Exist?
if (resultCount.IDEXISTS eq 1){
//do login
}
else {
getPlugin("messagebox").setMessage("error", "Sorry, Username/Password not
found.");
}
}
else {//We Have Validation Errors Show The User A Message
getPlugin("messagebox").setMessage("error", "<b>The
Following Validation Errors Occurred:</b><br />",errors);
}
Few questions.
Is what I am doing OK?
service <-- passes in the admin bean needs the gateway
gateway < -- my sql only acced from the service
admin.cfc <--- getters and setters, right?
correct right?
what are the benefits of me create the userBean above passing that into the
getPlugin('beanFactory').populateBean(userBean); then using it and not the
direct gateway?
--------------------
my service
<!---gets the gateway so it can be access via the service layer--->
<cffunction name="setadminUsersGateway" access="public" returntype="void"
output="false">
<cfargument name="adminUsersGateway" required="true"
type="salesMaxx.model.adminUsersGateway" />
<cfset variables.adminUsersGateway = arguments.adminUsersGateway />
</cffunction>
<!---creates the AdminUser Bean--->
<cffunction name="createAdminUserBean" access="public"
returntype="salesMaxx.model.adminUsers" output="false">
<cfset var bean =
createObject('component','salesMaxx.model.adminUsers').init(createUUID()) />
<cfreturn bean />
</cffunction>
<cffunction name="validateCredentials" access="public" returntype="any"
output="false">
<cfargument name="bean" type="salesMaxx.model.adminUsers" required="true" />
<cfset result = variables.adminUsersGateway.existsAdminUsers(arguments.bean)
/>
<cfreturn result />
</cffunction>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know
on the House of Fusion mailing lists
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:325453
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4