I'm new to MG3 and have been trying to learn the framework by reviewing the
docs and other developers code, specifically LHP. I still have a ways to
go to get up to speed . I have run into a frustrating issue that I can not
resolve. Any help would certainly be appreciated.
A simple client table in DB.
The event page.clients returns the full list of clients properly. No
problem there. However, when I link from page.clients to page.client and
pass the clientID to the ClientController, my struct is always empty.
*page.client*
<cfset client = event.getValue("client") />
<cfdump var="#client#" label="clientDetails">
*ClientController*
*
*
<cffunction name="getClient" access="public" output="false">
<cfargument name="event" type="any">
<cfset var clientid = arguments.event.getValue("clientID") />
<cfset var client = beans.clientService.getClient(clientID) />
<cfset arguments.event.setValue("client", client)>
</cffunction>
*Model*
*
*
*ClientService*
*
*
<cffunction name="getClient" access="public" returntype="any"
output="false" hint="Gets a client bean based on the client's ID.">
<cfargument name="clientID" type="any" required="false">
<cfif structKeyExists(arguments,"clientID") and arguments.clientID NEQ 0>
<cfreturn variables.gateway.getClient(arguments.clientID)>
<cfelse>
<cfreturn variables.gateway.newClient()>
</cfif>
</cffunction>
*ClientGateway*
*
*
<cffunction name="getClient" access="public" returntype="clientBean"
output="false">
<cfargument name="clientID" type="any" required="true">
<cfset var cBean = createObject("component", "ClientBean") />
<cfset var clientData = "" />
<cfquery name="clientData" datasource="#variables.dsn#"
username="#variables.username#" password="#variables.password#">
SELECT clientID, clientname, clientaddress, clientcity, clientstate,
clientzipcode, clientphonenumber, clientdateadded
FROM dbo.clients
WHERE clientid = <cfqueryparam value="#arguments.clientID#" />
</cfquery>
<cfif clientData.recordCount>
<cfset cBean.setClientID(clientData.clientid) />
<cfset cBean.setClientName( clientData.clientname) />
<cfset cBean.setClientAddress(clientData.clientaddress) />
<cfset cBean.setClientCity(clientData.clientcity) />
<cfset cBean.setclientstate(clientData.clientstate) />
<cfset cBean.setClientZipcode(clientData.clientzipcode) />
<cfset cbean.setClientPhoneNumber(clientData.clientphonenumber) />
<cfset cbean.setClientDateAdded(clientData.clientdateadded) />
</cfif>
<cfset cBean.setConfig(variables.config) />
<cfreturn cBean>
</cffunction>
*
*
*ClientBean*
*
*
<cfset variables.instance = structNew() />
<cfset variables.instance.clientid = 0 />
<cfset variables.instance.clientname = "" />
<cfset variables.instance.clientaddress = "" />
<cfset variables.instance.clientcity = "" />
<cfset variables.instance.clientstate = "" />
<cfset variables.instance.clientzipcode = "" />
<cfset variables.instance.clientdateadded = "" />
{{{ setting and getting all columns }}}
All the accessors are referenced... followed by the instance
<cffunction name="getInstance" returntype="struct" access="public"
output="false">
<cfreturn duplicate(variables.instance)>
</cffunction>
<cffunction name="setConfig" returntype="void" access="public"
output="false" hint="Used to allow beans to inject settings">
<cfargument name="config" type="any" required="true">
<cfset variables.config = arguments.config>
</cffunction>
I have made a dozen changes and I can not get the specific client details
returned to the page.client event. I try and dump the result and it
returns
clientDetails - struct [empty]
Frustrated.
My user model is working fine and is almost the exact same code...
--
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog
You received this message because you are subscribed to the Google
Groups "model-glue" 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/model-glue?hl=en