Hi Chris, I ran into this issue myself for the 2nd time today, and wound up
back here at your post again. :) Looking at the current code in
EventContext.cfc (perhaps it's been updated since you posted this?), I'm
thinking that the idea of passing a struct of your url params is already
supported in the core, and we just need to modify the actual UrlManager
itself. I say that because the 2nd argument ("append") has no type
specified. So, with that in mind, here's my modified UrlManager.cfc, linkTo
function, which is working quite well for me. Note that I didn't like
upper-case variable names for my url params, so I did an otherwise
unnecessary lcase(). <cffunction name="linkTo" output="false" hint="Builds a
link to the specified event, appending the listed values from the context
and the anchor position specified."> <cfargument name="event" default=""
hint="The event to which the url should link." /> <cfargument name="append"
default="" hint="The list of values to append." /> <cfargument name="anchor"
default="" hint="The anchor literal for the resultant URL." /> <cfargument
name="eventContext" default="" hint="Required if using append." /> <cfset
var link =
"#variables._mg.configuration.defaultTemplate#?#variables._mg.configuration.eventValue#="
/> <cfset var i = "" /> <!--- Add the event ---> <cfset link = link &
arguments.event /> <!--- Add values ---> <cfif isStruct(arguments.append)>
<cfloop collection="#arguments.append#" item="i"> <cfset link = link &
formatUrlParameter(lcase(i), urlEncodedFormat(arguments.append[i])) />
</cfloop> <cfelseif isSimpleValue(arguments.append)> <cfloop
list="#arguments.append#" index="i"> <cfset link = link &
formatUrlParameter(lcase(i),
urlEncodedFormat(arguments.eventContext.getValue(i))) /> </cfloop> </cfif>
<!--- Add anchor ---> <cfif len(arguments.anchor)> <cfset link = link &
"###arguments.anchor#" /> </cfif> <cfreturn link /> </cffunction> Let me
know what you think. I may also end up blogging this.
I also made use of the formatUrlParameter function so that I could copy the
same code into my SesUrlManager.cfc.
Here's how I'm implementing it in a view:
<cfset userMenus = event.getValue("userMenus", ArrayNew(1)) /> <cfoutput>
<ul> <cfloop array="#variables.userMenus#" index="mnu"> <cfset tmp = {cal =
variables.mnu.getMenuId()} /> <li><a href="#event.linkTo('calendar.display',
variables.tmp)#">#variables.mnu.getMenuName()#</a></li> </cfloop> </ul>
</cfoutput>
-Adam
On Thu, May 29, 2008 at 3:45 AM, Chris <[EMAIL PROTECTED]> wrote:
> I wanted to extend SesUrlManager so that i could pass in a struct of url
> params that would be looped over and added to the end of my url. I thought
> this would be as simple as overriding the linkTo() method in my cfc... But
> when i looked into it a bit closer i found that i was not calling the method
> in the urlmanager directly, it was passed through EventContext.linkTo() and
> this method has a different signature (uses "eventName" rather than "event")
> and passes its arguments on in an ordered fashion.
>
> So heres my suggestion. Change the url managers to use "eventName" as the
> first argument, this removes any ambiguity and alter EventContext.linkTo()
> to pass arguments to UrlManager.linkTo() using argumentCollection.
>
> These changes should not break any existing sites and would allow
> developers to add extra arguments to their own urlmanagers without the need
> to touch the framework code.
>
> Any thoughts?
>
> Cheers, Chris
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---