If I'm not mistaken, this actually isn't a Model-Glue issue, but a problem
due to a scope conflict.
When doing this:
<cfset client = event.getValue("client") />
<cfdump var="#client#" label="clientDetails">
You are creating a variable named "client" in the variables scope of the
page, but the dump is referencing the client scope (which in this case is
an empty struct). If you dump "variables.client" instead, you should see
your object.
That said, I would strongly recommend against using variable names that are
also CF scopes (client, session, url, etc.), as that can often result in
exactly this kind of confusing behavior.
--
Ezra Parker
On Tue, Jul 17, 2012 at 1:53 PM, Dan Wilson <[email protected]> wrote:
>
> Usually, when this happens, it's because you aren't accessing the
controller function.
>
> There are two common reasons for this. Either your application is set to
not reload, and you've added the controller stuff without manually
reloading your application, or you aren't calling the controller method to
begin with.
>
> The easiest way to figure this out is to turn reload on and also turn
debug on in your ColdSpring.xml. See below for a snippet:
>
> <bean id="modelglue.modelGlueConfiguration"
class="ModelGlue.gesture.configuration.ModelGlueConfiguration">
>
> <!-- Be sure to change these to false when you go to production! -->
> <property name="reload"><value>true</value></property>
> <property name="debug"><value>true</value></property>
>
>
> You will need to manually reload your application for the changes to be
picked up. Once you do, you should have a bunch of debug messages below.
Look for the name of the message that you have in your event that is linked
to the getClient() method in your controller. If it isn't there, you can
start to match up the Message name, with the message-listener message
attribute in your controller.xml declaration.
>
> If you haven't figured it out by then, post the ModelGlue.xml
configuration on http://pastebin.com and post the URL of the pastebin back
to this thread.
>
>
> DW
>
>
>
>
> On Tue, Jul 17, 2012 at 4:33 PM, Craig Derington <[email protected]>
wrote:
>>
>> 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
>
>
>
>
> --
> Plutarch - "The mind is not a vessel to be filled but a fire to be
kindled."
>
> --
> 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
--
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