Linkto() not working as expected

5 views
Skip to first unread message

David Mineer

unread,
Feb 9, 2009, 12:51:33 AM2/9/09
to model...@googlegroups.com
MG3

I have a linkto: <a href="#event.linkTo('firsttry','userid,profileid')#">First Try</a>

But the URL passed is http://test/index.cfm/firsttry/userid//profileid/

Shouldn't it put the values after the names between the //?  Should be:

http://test/index.cfm/firsttry/userid/1/profileid/dave

I do have a cfset userid = 1 and profileid = 'dave'

Am I misunderstanding how linkto() works?

--
David Mineer Jr
---------------------
The critical ingredient is getting off your
butt and doing something. It's as simple
as that. A lot of people have ideas, but
there are few who decide to do
something about them now. Not
tomorrow. Not next week. But today.
The true entrepreneur is a doer.

Brian Kotek

unread,
Feb 9, 2009, 1:04:14 AM2/9/09
to model...@googlegroups.com
Do you actually have event arguments named userid and profileid?

David Mineer

unread,
Feb 9, 2009, 7:46:14 AM2/9/09
to model...@googlegroups.com
Well, that's where I am a little confused.  How do I get them into event if I don't pass them in the url.  Like I mentioned in the email, I set those on the page and normally would add them to the "a href" hyperlink and then they would be passed in the url and be available in the event scope.

Normally I would build he hyperlink like this http://test/index.cfm?event=firsttry&userid=#userid#&profileid=#profileid#

I assumed the linkto() would do that.

How do I get those values to the event scope?

Jason Fisher

unread,
Feb 9, 2009, 7:58:47 AM2/9/09
to model...@googlegroups.com
If the variables do not already exist in the event when you call linkTo(), then you'll need to set them with event.setValue("userid", "1") and event.setValue("profileid", "Dave").

Jason Fisher

unread,
Feb 9, 2009, 7:58:47 AM2/9/09
to model...@googlegroups.com

Jason Fisher

unread,
Feb 9, 2009, 7:58:47 AM2/9/09
to model...@googlegroups.com

Adam Tuttle

unread,
Feb 9, 2009, 9:33:12 AM2/9/09
to model...@googlegroups.com
I wrote a custom URL Manager for this reason, which expands on the current one to keep its existing functionality, but if the 2nd argument is a structure instead of a string, it uses the key/value pairs from the structure instead of pulling the values out of the event context.

Here's my basic version: http://atuttle.pastebin.com/f31871859

And my SES version: http://atuttle.pastebin.com/feb8ff93

Adam

David Mineer

unread,
Feb 9, 2009, 5:30:10 PM2/9/09
to model...@googlegroups.com
So what do people do?  I must be thinking wrong here.  If you have a list of unique id's how do you set up those links with MG3:

<CFOUTPUT query="myQuery">
<a href="showdetail?myrecordid=#myQuery.id#
</CFOUPTUT>

Is Adam's solution the only way I can do this.  What would everyone else do?  I do feel that SES is very important.


On Mon, Feb 9, 2009 at 7:33 AM, Adam Tuttle <j.adam...@gmail.com> wrote:
I wrote a custom URL Manager for this reason, which expands on the current one to keep its existing functionality, but if the 2nd argument is a structure instead of a string, it uses the key/value pairs from the structure instead of pulling the values out of the event context.

Here's my basic version: http://atuttle.pastebin.com/f31871859

And my SES version: http://atuttle.pastebin.com/feb8ff93

Adam



David Mineer

unread,
Feb 18, 2009, 12:28:11 AM2/18/09
to model...@googlegroups.com
Bump.
 
I would really like to hear how people handle this.  Forgive the bump.
 
How can I do the following with linkto():
 
<a href="Showdetail?myrecordid=#id#>Show Detail</a>
 
I use this type of link alot to pass variables.  Is it bad? Is there a better way that allows me to use linkto()?
 
Thanks,

Sean Coyne

unread,
Feb 18, 2009, 7:55:48 AM2/18/09
to model-glue
The value ID must be set into the event first.

so if you have a local variable called ID already set, just set it in
the event right in the view.
<cfset id = 1 />
<cfset event.setvalue('id',id) />
<cfoutput><a href="#event.linkTo('some.event','id')#">Link</a></
cfoutput>

This will create a link like /?event=some.event&id=1

Sean


On Feb 18, 12:28 am, David Mineer <min...@gmail.com> wrote:
> Bump.
>
> I would really like to hear how people handle this.  Forgive the bump.
>
> How can I do the following with linkto():
>
> <a href="Showdetail?myrecordid=#id#>Show Detail</a>
>
> I use this type of link alot to pass variables.  Is it bad? Is there a
> better way that allows me to use linkto()?
>
> Thanks,
>
>
>
> On Mon, Feb 9, 2009 at 3:30 PM, David Mineer <min...@gmail.com> wrote:
> > So what do people do?  I must be thinking wrong here.  If you have a list
> > of unique id's how do you set up those links with MG3:
>
> > <CFOUTPUT query="myQuery">
> > <a href="showdetail?myrecordid=#myQuery.id#
> > </CFOUPTUT>
>
> > Is Adam's solution the only way I can do this.  What would everyone else
> > do?  I do feel that SES is very important.
>

David Mineer

unread,
Feb 18, 2009, 9:38:18 AM2/18/09
to model...@googlegroups.com
Thank you.  That makes sense.  For some reason I didn't realize you could mess with the event object in the view. 

On Wed, Feb 18, 2009 at 5:55 AM, Sean Coyne <coyne...@gmail.com> wrote:

The value ID must be set into the event first.

so if you have a local variable called ID already set, just set it in
the event right in the view.
<cfset id = 1 />
<cfset event.setvalue('id',id) />
<cfoutput><a href="#event.linkTo('some.event','id')#">Link</a></
cfoutput>

This will create a link like /?event=some.event&id=1

Sean

Sean Coyne

unread,
Feb 18, 2009, 12:06:09 PM2/18/09
to model-glue
in MG3 the viewstate is gone. the event is the same in the controller
and in the view.

On Feb 18, 9:38 am, David Mineer <min...@gmail.com> wrote:
> Thank you.  That makes sense.  For some reason I didn't realize you could
> mess with the event object in the view.
>

David Mineer

unread,
Feb 18, 2009, 1:10:29 PM2/18/09
to model...@googlegroups.com
Ok, I played with setting the value in the event and that works.

But I don't think that would work if I was iterating over a query and had no idea which one of the rows the user was going to click on.  Since I have no idea which of the row id's to set in the event, I wouldn't be able to set the value into the event, right?

And I wouldn't be able to set the event on each row, because at the end the event.value would equal the value set from the last row of the query.

Still a little confusing.  Any ideas?

Chris Blackwell

unread,
Feb 18, 2009, 2:14:14 PM2/18/09
to model...@googlegroups.com
Just set it for each row of the query

<cfloop query="myquery">
   <cfset event.setValue("id", myquery.id)>
   <cfoutput><a href="#event.linkTo('some.event','id')#">Link</a></cfoutput>
</cfloop>

admittedly it doesn't feel quite right doing it like this, but what problem does leaving the value of id equal to the last row of the query cause?


2009/2/18 David Mineer <min...@gmail.com>

David Mineer

unread,
Feb 18, 2009, 6:42:56 PM2/18/09
to model...@googlegroups.com
If that code loops over, say, 10 rows, and you set the id variable in event, aren't you just overwriting it each iteration of the loop?

<cfset event.setValue("id", '1')>
<cfset event.setValue("id", '2')>
<cfset event.setValue("id", '3')>

Wouldn't event.getValue() = 3 at this point?

Chris Blackwell

unread,
Feb 18, 2009, 6:48:47 PM2/18/09
to model...@googlegroups.com
yes it would, but i dont see what the problem is. you set the value then you output the link, both within the loop...

2009/2/18 David Mineer <min...@gmail.com>

David Mineer

unread,
Feb 19, 2009, 1:37:32 AM2/19/09
to model...@googlegroups.com
But if you click on 1 or 2 you still get 3. Wyen the page is done
rendering the value can only be equal to one thing, in this case 3. I
am confusing myself too and typing from my phone.
--
Sent from my mobile device

Sean Coyne

unread,
Feb 19, 2009, 7:55:35 AM2/19/09
to model-glue
The view isn't rendered after you have done the loop. Each line will
be rendered with each iteration of the loop. 1 and 2 will have the
correct ID and 3 will say 3.

Sean
Reply all
Reply to author
Forward
0 new messages