Making a link often entails request level parameters, this is why event.linkTo 
makes a single link at a time.



Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: Chuck Savage <[email protected]>
Date: Mon, 30 Nov 2009 11:20:15 
To: model-glue<[email protected]>
Subject: [Model-Glue] Re: helper for 'myself' & something

Dan how does that save me, except perhaps read-ability on the
standpoint of someone else coming to the project at a later time.  I
do like the copyToScope(), but it should go a step further and do a
link at the same time, or with a different function. Oh well, I came
up with this in the meantime,

<cfparam name="Attributes.e" type="string" />
<cfparam name="Attributes.variable" type="string"
default="#Attributes.e#" />
<cfparam name="Attributes.state" type="struct"
default="#CALLER.viewState#" />

<cfif thisTag.ExecutionMode is 'start'>
        <cfset myself = Attributes.state.GetValue('myself')>
  <cfset event = Attributes.state.GetValue(Attributes.e)>
        <cfset CALLER["#Attributes.variable#"] = myself & event>
</cfif>

So a <cf_myself e="xe.register"> will create a variable xe.register
that points to the page.  I like the optional list of copyToScope, so
I'll modify it so I can do <cf_myself
e="xe.reset,xe.delete,xe.ignore,xe.unignore"> and get the same results
for each.

On Nov 30, 11:23 am, Dan Skaggs <[email protected]> wrote:
> Chuck...
>
> Are you using MG3?  If so, you should look at the new copyToScope() and
> event.linkto() functionality. It's designed to replace the "myself" code
> that you included below.
>
> For example instead of having to do all those viewState.GetValue calls,
> you could put this code at the top of your page:
> <cfset event.copyToScope("variables",
> "xe.reset,xe.delete,xe.ignore,xe.unignore") />
>
> That single line will copy all those values from the event object into
> the variables scope of your view page.  Then you can use the
> event.linkTo() method to build your URLs like so:
>
> <cfset resetPage = event.linkTo( xe.reset ) />
> <cfset deletePage = event.linkTo( xe.delete ) />
>
> You can then continue to use the resetPage, deletePage and other
> variables like you have been before.
>
> Hope that helps,
> Dan
>
> On 11/30/2009 12:12 PM, Chuck Savage wrote:
>
> > Anyone have a good helper that combines 'myself' and other?
>
> > I find that I'm writing ...
>
> > <cfset loginPage = viewstate.getValue("myself")&  viewstate.getValue
> > ("xe.Login") />
> > <cfset logoutPage = viewstate.getValue("myself")&  viewstate.getValue
> > ("xe.Logout") />
> >   on one page, then another
>
> > <cfset myself = viewState.GetValue('myself')>
> > <cfset self = myself&  viewState.GetValue('event')>
> > <cfset resetPage = myself&  viewState.GetValue('xe.reset')>
> > <cfset deletePage = myself&  viewState.GetValue('xe.delete')>
> > <cfset ignorePage = myself&  viewState.GetValue('xe.ignore')>
> > <cfset unignorePage = myself&  viewState.GetValue('xe.unignore')>
>
> > etc etc.  Its getting old fast.  I need something smoother and less
> > verbose.
>
> > Related, can helper cfc's get injected with the event scope/bean?
>
> > I'm thinking a custom tag that does something like<cf_myself
> > variable="loginPage" e="xe.Login">
> > 'variable' being optional, otherwise variable would be the value
> > passed into e, so internally to the tag would basically be:
>
> > <cfparam name="Attributes.e" type="string" />
> > <cfparam name="Attributes.variable" type="string"
> > default="#Attributes.e#" />
> > <cfset "#Attributes.variable#" = viewState.getValue("myself")&
> > viewState.getValue(Attributes.e)>

-- 
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

Reply via email to