Cool :) One last thing before I get on and fix all my var scopes, is the init function required in a MG controller? All mine is..
<cffunction name="init" access="public" output="false" hint="Constructor" > <cfreturn this /> </cffunction> On Thu, Jun 23, 2011 at 7:07 AM, Jim Priest <[email protected]> wrote: > From: > http://docs.model-glue.com/wiki/ReferenceMaterials/ColdSpringXmlReference/ModelGlueConfiguration#Model-GlueConfigurationSettingDefinitions > > StatePrecedence > > Possible values are FORM and URL. > > Model-Glue combines all values from FORM and URL into a single > structure called the viewstate. If STATEPRECEDENCE is set to FORM, > FORM variables will overwrite like-named URL variables. If set to URL, > the opposite will occur. > > > On Wed, Jun 22, 2011 at 4:57 PM, Matt Quackenbush <[email protected]> > wrote: > > As a general rule, it should not matter where it came from (form vs. > url). > > If you have a specific use case you *must* know, then you'd just have to > > check the specific scope. But such a use case is quite abnormal. > > > > As for what happens, the form scope takes precedence over the url scope. > > So, in the scenario you presented, the url.uuid would simply be ignored. > > (There might be a setting to reverse that, but I'm not sure off the top > of > > my head.) > > > > On Wed, Jun 22, 2011 at 3:53 PM, Brett Herford-Fell < > [email protected]> > > wrote: > >> > >> Thanks guys, > >> With the form / url variables in the event scope, does it identify which > >> are which? > >> E.g if I want to loop through all the variables that are form variables > in > >> the event scope, can I do that? > >> Also, if there url has "uuid", and the form has "uuid", what happens > here? > >> Many thanks, > >> b > >> > >> On Thu, Jun 23, 2011 at 12:22 AM, Dan Wilson <[email protected]> > wrote: > >>> > >>> Ok > >>> > >>> I added the following two FAQ articles: > >>> > >>> > >>> > http://docs.model-glue.com/wiki/FAQs/WhyAreControllerVariablesBeingIncorrectlySharedAcrossUserRequests > >>> > >>> > http://docs.model-glue.com/wiki/FAQs/DoINeedToUseCFParamForFormAndURLVariables > >>> > >>> As this is a public wiki, anyone on the list is free to clarify > >>> statements or add sections they feel would help others. > >>> > >>> > >>> DW > >>> > >>> > >>> On Wed, Jun 22, 2011 at 9:37 AM, Dan Skaggs < > [email protected]> > >>> wrote: > >>>> > >>>> Sure...glad to help. > >>>> Dan > >>>> On Jun 22, 2011, at 8:30 AM, Dan Wilson wrote: > >>>> > >>>> Hey Dan, > >>>> > >>>> That's a great explanation. Do you mind if I add some of your post to > >>>> the FAQ section on the Wiki? > >>>> > >>>> > >>>> DW > >>>> > >>>> On Tue, Jun 21, 2011 at 9:29 PM, Dan Skaggs < > [email protected]> > >>>> wrote: > >>>>> > >>>>> Couple of things here: > >>>>> > >>>>> 1) Passing your entire populated model object to the view (via the > >>>>> ModelGlue event object) is perfectly fine. There's no reason to break > out > >>>>> all the object's properties into separate values in the event. > >>>>> > >>>>> 2) ModelGlue controllers are created once on application init (or > when > >>>>> you manually reinit the app) and cached. Therefore, yes, the > controller > >>>>> objects are in effect singletons for the application. > >>>>> > >>>>> 3) Instead of doing <cfset variables.item ...>, you should do <cfset > >>>>> var item = createObject(.....) />. Using variables.item actually > would set > >>>>> the object into the global memory space for the controller component > (which > >>>>> would be bad as that value is then cached as part of the controller > >>>>> singleton--see #2). Using the "var" keyword on a variable inside a > function > >>>>> body ensures that the variable only exists for that execution of the > >>>>> function (therefore it can't be stored and bleed over into other > requests > >>>>> that execute that same function). The variable is discarded after the > >>>>> function completes executing. > >>>>> > >>>>> 4) Using the var keyword has nothing to do with the user > session--they > >>>>> are 2 completely different ideas. > >>>>> > >>>>> 5) There's no need to cfparam the url.uuid. ModelGlue automatically > >>>>> puts all URL and form variables into the event object for you to make > it > >>>>> easy for you to find them. You just need to get the value out of the > event > >>>>> when you need it (see below). Should uuid not exist in the event, > ModelGlue > >>>>> will return you an empty string. You can optionally set a default > value to > >>>>> use in case the variable doesn't exist in the event (see > >>>>> > http://docs.model-glue.com/wiki/ReferenceMaterials/EventApi#GetValuename:stringdefault:any > >>>>> for more information). > >>>>> > >>>>> Try updating your controller component as such: > >>>>> > >>>>> <cfcomponent output="false" > >>>>> extends="ModelGlue.gesture.controller.Controller"> > >>>>> > >>>>> <cffunction name="view" access="public"> > >>>>> <cfargument name="event" /> > >>>>> > >>>>> <cfset var uuid = arguments.event.getValue( "uuid" ) /> > >>>>> <cfset var item = CreateObject("component", "model.item") /> > >>>>> <cfset var status = "" /> > >>>>> > >>>>> <cfinvoke component="#item#" > >>>>> method = "get" > >>>>> returnvariable = "status" > >>>>> uuid = "#uuid#" > >>>>> > > >>>>> > >>>>> <cfset arguments.event.setValue("item", item) /> > >>>>> > >>>>> </cffunction> > >>>>> </cfcomponent> > >>>>> > >>>>> Additionally, while there's nothing wrong technically with using a > >>>>> <cfinvoke> there, you could shorten that up like so: > >>>>> > >>>>> <cffunction name="view" access="public"> > >>>>> <cfargument name="event" /> > >>>>> > >>>>> <cfset var item = CreateObject("component", "model.item") /> > >>>>> > >>>>> <cfset item.get( uuid = arguments.event.getValue( "uuid" ) ) > /> > >>>>> > >>>>> <cfset arguments.event.setValue("item", item) /> > >>>>> > >>>>> </cffunction> > >>>>> </cfcomponent> > >>>>> > >>>>> Hope that helps clarify things a bit. If there's something you don't > >>>>> understand, be sure to ping us back. > >>>>> > >>>>> Dan > >>>>> > >>>>> On Jun 21, 2011, at 8:09 PM, Brettski wrote: > >>>>> > >>>>> > And should I scope like > >>>>> > > >>>>> > <cfset Variables.item = CreateObject("component", "model.item")> > >>>>> > .. > >>>>> > <cfset arguments.event.setValue("item", Variables.myItem) /> > >>>>> > > >>>>> > > >>>>> > On Jun 22, 11:01 am, Brettski <[email protected]> wrote: > >>>>> >> the model bits and pieces are all used in the view, am I thinking > >>>>> >> wrong to pass all this back to view? What else should I pass back > a > >>>>> >> struct or something? > >>>>> >> > >>>>> >> My vars aren't scoped, so does this mean there is one controller > >>>>> >> "instance / singleton" for the app, and if I don't scope them they > >>>>> >> can > >>>>> >> bleed? I think that's if I scope all vars they will stay in user > >>>>> >> session? > >>>>> >> > >>>>> >> On Jun 22, 9:55 am, Roy Martin <[email protected]> wrote: > >>>>> >> > >>>>> >> > >>>>> >> > >>>>> >> > >>>>> >> > >>>>> >> > >>>>> >> > >>>>> >>> Off the cuff, you haven't var scoped your 'item' variable or your > >>>>> >>> return > >>>>> >>> variable 'status'. So those variable will be subject to variable > >>>>> >>> bleed under > >>>>> >>> load. As an additional point of feedback, passing the entire > model > >>>>> >>> back to > >>>>> >>> the view isn't best practice. It would be better if you had > passed > >>>>> >>> just the > >>>>> >>> return variable back to the model. Unless that's a typo? > >>>>> >> > >>>>> >>> Thanks, > >>>>> >>> Roy > >>>>> > > >>>>> > -- > >>>>> > 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 > >>>> > >>>> > >>>> -- > >>>> 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 > >>> > >>> > >>> -- > >>> 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 > > > > -- > > 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 > -- 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
