Conditional branching

0 views
Skip to first unread message

Al

unread,
Oct 26, 2009, 3:26:53 PM10/26/09
to model-glue
I have a simple form that a user can get to from multiple routes. I'd
like to be able to send them back to their origin once the form
completes processing. My ideas so far seem awfully klugey.

How have others solved this sort of thing in the past? (I am using
Model Glue 2.)

Rich

unread,
Oct 26, 2009, 4:10:24 PM10/26/09
to model...@googlegroups.com
... I usually just sit back and watch these threads so as to learn new
things, but only because I've literally just finished a similar task
do I feel compelled to chime in....

I have a 2 page form that a user can access from 5 different routes
and all are based on the date (I center on today's date, for
perspective).

My url var is named orderDate. So as to keep my forms dynamic, I
appended "currentDay", "prevDay", "nextDay", "history" and "future" to
the calling urls (www.myurl.com?
action=order.myAction&orderDate=currentDay) simply deriving the value
of orderDate with some logic and dateAdd(). I passed the value along
using a hidden field and then finally in the controller I did a <cfset
arguments
.event.setValue("orderDate","#arguments.event.getValue('orderDate')#")/
>.

The result page url is something like www.myurl.com?
action=order.myActionReturn&orderDate=currentDay (or whatever the
orderDate var was set to based on what date the user originally
clicked on). My code sees viewstate.getValue("orderDate") and goes
about it's business.

This makes sense to my use case and solves the problems I was facing
with where to land the user after they submitted the form; essentially
all I did was set the navigation at the beginning of the process,
carry it through the form, then through to the MG framework so that it
could be referenced on the way out.

HTH, and I'd also like to see how others have done this - always
learning!

Rich
Rich

Rich Leach
Advanced Certified Adobe ColdFusion Developer
ri...@cfsnap.com

Chuck

unread,
Nov 16, 2009, 4:04:47 PM11/16/09
to model-glue
I use two methods in my basic login form. The form can be included
with cfinclude, or it can be called directly with a link. So, using
both, I have this code at the top of the file...

<cfset ThisPage=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset ThisPage=ThisPage & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>

<cfif IsDefined("FORM.username")>
<cfset loginInfo = StructNew()>
<cfset loginInfo.username = FORM.username>
<cfset loginInfo.password = FORM.password>
<cfset REQUEST.mcp.call('secure:login',loginInfo)>

<!--- if page passed as a URL, transfer to this page instead after
a login attempt --->
<cfif StructKeyExists( URL, 'page' )>
<cflocation url="#URL.page#" addtoken="no" />
</cfif>
<!--- Reload this page, if login succeeded, it will proceed as
normal --->
<cflocation url="#ThisPage#" addtoken="no">

</cfif>

<cfform ...>
</cfform>

At the top of the including page I have...

<cfif NOT AUTHORIZED check roles etc >
<div align="center">
Some text above login form<br><br>
</div>
<cfinclude template="#REQUEST.PATH.lib#/login.cfm" />
<cfelse>
.. rest of page to authorized viewers
</cfif>

so the include method works well too, because once proper access
authorized, it returns to the right page, because technically it never
left it, and executes the remainder of the code.
Reply all
Reply to author
Forward
0 new messages