How to run a coldfusion template continuously

How do a display 4 pages one page at a time and continuously in coldfusion?
SonnyReyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurpreet Singh RandhawaCEOCommented:
well did not under stood ur question properly

two ways:

random way


<cfquery name="pages">
select * from pages
</cfquery>

<cfset all = randRange(1,pages.recordcount)>
<cfoutput>#all#</cfoutput>


now if you save pages info in the database this works that way:

if you have a list like this

<cfset allpages = "abc.cfm,bbb.cfm,qqq.cfm,nnn.cfm">
<cfset randpage = randRange(1,#allpages#)>
<cflocation url="#randpage#">

So everytime it will locate to page which it finds randomly

Let us know if something else
0
ZvonkoSystems architectCommented:
You want to display: page1.cfm -> page2.cfm -> page3.cfm ->page4.cfm -> page1.cfm ->...

Right?

What time delay do you want for each page to be the display in seconds?

0
SonnyReyAuthor Commented:
That's exactly what I wanted to do.
About 10 seconds delay per page display.
I want to put the delay (seconds) in a table.
Thanks.
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

SonnyReyAuthor Commented:
That's exactly what I wanted to do. Go from page to page
and back to the first page with a fixed time delay in seconds.
page1.cfm -> page2.cfm -> page3.cfm ->page4.cfm -> page1.cfm ->...
About 10 seconds delay per page display.  I need to run this
continuously all day. I want to put the delay (seconds) in a table.
Thanks
0
azadisaryevCommented:
here's how you could do it using session var (see attached code).

some notes:
- make sure session management is enabled in your application (i.e. you have sessionmanagement="yes" in your Application.cfc/cfm)
- save the cfc as test.cfc in the same folder as page1.cfm and page2.cfc
- javascript uses jquery library (http://jquery.com/). the library is loaded from google APIs cdn.
- load page1.cfm in your browser, then toggle the div display by clicking on the 'show/hide' button. now click the 'go to page 2' link - the div on page2 will be in the same state you left it on page1

Azadi
<!--- the cfc. save it as test.cfc in the same folder as cfm pages --->
<cfcomponent output="no">
	<cffunction name="setDivState" access="remote" returntype="void">
		<cfargument name="state" type="boolean" required="no" default="0">
		<cflock scope="session" timeout="2" type="exclusive">
			<cfset session.divState = arguments.state>
		</cflock>
	</cffunction>
</cfcomponent>

<!--- page1.cfm --->
<cfparam name="session.divState" default="0"><!--- cfparam our session var --->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	var flip = <cfoutput>#session.divState#</cfoutput>; // set flip var to current value of session.divState var
	if (flip % 2 == 1) $("#seasondata").css('display', 'block'); // set initial display of our div based on session var value
	$("#toggleDiv").click(function(){ // bind this to clikc event of the button
		$("#seasondata").toggle(flip++ % 2 == 0); // toggle our div based on value of flip var
		$(this).attr('value', ((flip % 2 == 0) ? 'Show' : 'Hide') + ' Div'); // change the text displayed on the button
		$.get('test.cfc?method=setDivState&state='+(flip % 2)); // call the setDivState() method of our cfc via ajax to set session var value
	})
});
</script>
<h1>Page 1</h1>
<h3><a href="page2.cfm">Go to Page 2</a></h3>
<input type="button" id="toggleDiv" value="<cfif session.divState eq 0>Show<cfelse>Hide</cfif> Div" />
<br />
<br />
<div id="seasondata" style="border:1px solid black; background-color:#f0f0f0; text-align:center; display:none">
<p>This is a div you can show/hide</p>
</div>

<!--- page2.cfm --->
it is exactly the same as page1.cfm, just change the <h1> text to Page 2 and the link to point back to page1.cfm

Open in new window

0
azadisaryevCommented:
oops! sorry guys - posted answer in the wrong question!!!

Azadi
0
andrewlorienCommented:
It's really a javascript question - the server can't force a page refresh, only the browser can.  

here's the concept:  at the top of the page, you get the delay (and the list of pages or whatever) from your database.  then write a javascript function which replaces the current page with the next page after the delay.  it might be nice to add a timer on the page too, so your users don't get confused when the page suddenly flicks over.

<CFQUERY
    get delay between pages

<SCRIPT LANGUAGE="JAVASCRIPT">
    setTimeout to call a window.location function after the delay
0
_agx_Commented:
(no points...)

> I need to run this continuously all day.

Something's not adding up here.  What do these pages do and where should they be "running all day"? It wouldn't make sense for a user page, because the user's browser would have to remain open all day.  It sounds more like you may be talking about running background tasks ...? If so, those would be a run on the server as a scheduled task.  You create a task. Schedule it to run every x intervals (second, hours, etc..) and it runs unattended.  Is that what you're trying to do?

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_r-s_11.html
0
SonnyReyAuthor Commented:
It will run on a monitor in an off track station.  It will display the dividends of a horse racing event.
Page 1 is Exacta Dividends, Page 2 is Daily Double dividends, Page 3 are win/plac/show dividends,
then back to page1.
0
andrewlorienCommented:
javascript is the only way to force the client to switch pages.

settimeout('window.location = #nextURL#', '#delayMilliseconds#');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZvonkoSystems architectCommented:
In the page header you can use META REFRESH:

<meta http-equiv="refresh" content="10; URL=/your/path/page2.cfm" >

0
ZvonkoSystems architectCommented:
And to fetch it from a table then best fetch the value in Application.cfm and use it in meta tag as variable.
Next page also can be hard coded or based on current page lookup the successor page name from a table and use it from an Session variable.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.