Twitter: raymondcamden


Address: Lafayette, LA, USA

Ask a Jedi: Frames and Model-Glue

01-17-2007 4,927 views ColdFusion 2 Comments

Yesterday Dan asked the following question about frames and Model-Glue:

Basically, my question is about using frames within my application. I basically want to use a frame for my avigation that never gets reloaded and another frame below it for the page displays. The reason I am using a frame for the navigation is that I am also trying to implement chat functionality within my ColdFusion app. The chat core needs to sit in a page that doesn't get refreshed, thus my need for a frame within my application. How would I go about in setting up this layout with my application using the Model-Glue framework?

The short answer to this is that you don't do anything special for frames when it comes to Model-Glue. What is interesting is that a very similar issue came up last week. I was doing training for a group of developers using Model-Glue and Spry. When it came time to talk about the URL to use for Spry's AJAX requests, I made the point that requesting XML (or loading a frame) is no different than any other Model-Glue request.

So to take your frames request and show a practical example, let's first look at a simple example of framed code:

view plain print about
1<frameset cols="200,*" bordercolor="#333333" framespacing="2" border="5">
2 <frame src="navserver.cfm" name="frame_nav" resize="yes" marginwidth="0" marginheight="0" framespacing="0" title="Navigation">
3 <frame src="right.cfm?target=" name="frame_detail" id="frame_detail" resize="yes" marginwidth="0" marginheight="0" framespacing="0" title="Main window">
4</frameset>

In case folks are curious - these frames come from the ColdFusion administrator (the only site I know that actually uses frames). The code we want to focus on is the two frame tags. Note they both use a SRC attribute which points to a URL. So in a Model-Glue site, the frames could look like so:

view plain print about
1<frameset>
2 <frame src="index.cfm?event=page.leftframe">
3 <frame src="index.cfm?event=page.rightframe">
4</frameset>

So to make this absolutely crystal clear - there is nothing special about using frames or AJAX requests in Model-Glue. Just remember your URL format (index.cfm?event=X) and use it for your links.

p.s. Don't forget Model-Glue has a set of predefined variables in the viewState, including one for index.cfm?event=. So technically, to make a link to event X, you would normally use this:

view plain print about
1<cfoutput>
2<a href="#viewState.getValue("myself")#X">X</a>
3</cfoutput>

As a hint - I recommend copying out that myself value to a variable if you will have a lot of links on a page (like your display template).

2 Comments

  • Commented on 01-18-2007 at 7:50 AM
    A little off topic, but something Dan might want to look at, is cfchat (at http://cfchat.net/home/). We needed chat functionality for a few apps quite some time ago, and it worked like a charm. A lot cheaper than building your own as well.
  • Dan #
    Commented on 01-21-2007 at 2:13 AM
    Sam,

    Thanks for the link, but I need something based off of XMPP. I really love the Jabber world, so I think I will stick with what I have been developing. Using XMPP, a lot of external chat applications such as google talk will be able to communicate with my application. I am using the Smack library to take care of the XMPP protocol for me. I will probably release my Coldfusion/Smack library when I am done with it. It supports everything Smack supports, except I am not quite sure how I am going to pull off voice.

Post Reply

Please refrain from posting large blocks of code as a comment. Use Pastebin or Gists instead. Text wrapped in asterisks (*) will be bold and text wrapped in underscores (_) will be italicized.

Leave this field empty