Hey Irv,
We added a feature to Model-Glue 3.1M that I think resolves your issue but
it's not documented on the web site yet.
The linkTo() method has a new optional argument called preferredContext.
PreferredContext is a structure, and values in this structure override
corresponding values in the event when generating the link. You use this
structure to define local values for generating links on a page without
having to resort to event.setValue(). Example:
<cfscript>
preferredValues = {};
preferredValues.thisCalMonth = DateFormat(DateAdd("M", -1,
thisCalMonthStart), "YYYY-MM-DD");
prevmonthlink = event.linkTo( "pcalendar", "thisCalMonth",
"", preferredValues);
preferredValues.thisCalMonth = DateFormat(DateAdd("M", 1,
thisCalMonthStart), "YYYY-MM-DD");
nextmonthlink = event.linkTo( "pcalendar", "thisCalMonth",
"", preferredValues);
</cfscript>
When linkTo() sees "thisCalMonth" in the append list it will check first to
see if it exists in the preferredValues struct. Since it finds a matching
entry in the struct, it uses the value of that entry in the link. If it did
not find an matching entry, it would have gone back to using the value in
the event. You can have a mix of names in the append list where some are in
the struct and some are not; for each name, linkTo() will use the structure
value if available or the event value if not.
Sometimes in views you'd rather just use regular variables instead of
creating a dedicated structure: in that case you can use the variables scope
itself as the preferredContext. So in a view the above example could be
written like this:
<cfscript>
thisCalMonth = DateFormat(DateAdd("M", -1, thisCalMonthStart),
"YYYY-MM-DD");
prevmonthlink = event.linkTo( "pcalendar", "thisCalMonth", "", variables);
thisCalMonth = DateFormat(DateAdd("M", 1, thisCalMonthStart), "YYYY-MM-DD");
nextmonthlink = event.linkTo( "pcalendar", "thisCalMonth", "", variables);
</cfscript>
Of course, you should *NOT* use the variables scope this way in controllers.
Controllers are shared across requests and their variables scope persists
between calls, so that kind of code would create some nasty race conditions
where you'll get month values from other people's requests!!
On Wed, Aug 18, 2010 at 2:51 PM, Irv Wilson <[email protected]> wrote:
> Actually was kind of simple (I think). The problem I'm having with
> the below is I think of event.setValue as something sort of permanent
> that I'm sending back to the view instead of a "throw away" to make
> the two links...
>
>
> <cfset event.setValue(thisCalMonth, DateFormat(DateAdd("M", -1,
> thisCalMonthStart), "YYYY-MM-DD") />
> <cfset prevmonthlink = event.linkTo( "pcalendar", thisCalMonth />
>
> <cfset event.setValue(thisCalMonth, DateFormat(DateAdd("M", 1,
> thisCalMonthStart), "YYYY-MM-DD") />
> <cfset nextmonthlink = event.linkTo( "pcalendar", thisCalMonth />
>
> --
> 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]<model-glue%[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