Ticket #337 (closed defect: fixed)

Opened 17 years ago

Last modified 17 years ago

copyToScope() default array values overwrite event values

Reported by: Jamie Krug Owned by:
Priority: normal Milestone: 3.0
Version: 3.0.178 Severity: minor
Keywords: Cc:

Description (last modified by cfgrok) (diff)

Originally posted by Jamie Krug on 1/9/2009 at 1:26 PM: entered by Ezra Parker on port to new system

Environment: ModelGlue 3/Gesture svn rev 115 (latest ber as of 1/9/08), ColdFusion 8 developer edition, Ubuntu 8.04

When using the third, optional, argument (array of default values) to the event.copyToScope() method in a view, I find that any default values specified will take precedence over a value already in the event (e.g., specified in the query string).

For example, using the sample code provided at http://www.model-glue.com/blog/index.cfm/2008/9/9/New-Model-Glue-3-Feature-copyToScope ...

<cfset defaultArray = ["DefaultForFoot", "DefaultForHand"] />
<cfset event.copyToScope(variables, "foot,hand,xe.nested", defaultArray) />

This works as expected when no values exist in the event for the keys specified, but not when one of those values already exists in the event. For example, if the above code was in a view called by event=my.event, I'd expect this URL call...

http://localhost/index.cfm?event=my.event&foot=MyFootValue

...to produce these values in the variables scope:

foot = 'MyFootValue'
hand = 'DefaultForHand'
xe.nested = ''

Unfortunately, it is still setting variables.foot = 'DefaultForFoot' instead of the value specified in the query string.

If I change the view to use the "old fashioned" way, it works as expected, with:

foot = event.getValue('foot', 'DefaultForFoot');
hand = event.getValue('hand', 'DefaultForHand');
xe.nested = event.getValue('xe.nested');

I'm assuming I'm correct to expect copyToScope() to behave much like the above when defaults are specified, right?

If so, then I believe the following patch is the fix (for http://svn.firemoss.com/modelglue/trunk/ModelGlue/gesture/eventrequest/EventContext.cfc@115)

Thanks in advance Model-Glue Team!

Note: inline patches not included due to superceding attachments.

Attachments

EventContext-fixed.cfc (36.1 kB) - added by cfgrok 17 years ago.
MGG-21_fix_EventContext.diff (1.5 kB) - added by cfgrok 17 years ago.

Change History

Changed 17 years ago by cfgrok

Changed 17 years ago by cfgrok

Changed 17 years ago by cfgrok

  • description modified (diff)

Originally posted by Jamie Krug on 1/9/2009 at 1:32 PM: entered by Ezra Parker on port to new system

Formatting of code in issue description is messed up, so adding attachments of svn diff and a full fixed version of /modelglue/ModelGlue/gesture/eventrequest/EventContext.cfc

Changed 17 years ago by cfgrok

  • status changed from new to closed
  • resolution set to fixed

Originally posted by Dan Wilson on 1/12/2009 at 10:09 AM: entered by Ezra Parker on port to new system

Fixed in rev 116. Tested and verified by Jamie Krug

Note: See TracTickets for help on using tickets.