A challenge with creating any type of web application is ensuring that the user is able to seamlessly move from page to page. Forio Broadcast provides a special macro, #Link, that make it simple to create a user-friendly experience.
Saving Form Data
For example, in the following simulation, the user is able to enter decisions and click "submit". But what if the user clicks "Graphs" instead? If "Graphs" is a standard hyperlink, the information entered in the form is not submitted, and the user's decisions will not be processed.

With Forio Broadcast you can just enter a #Link macro and it will automatically include a check to see if a decision form is present and save the data if so.
Keeping Pages Fresh
A second common issue with web applications is how to keep dynamic content fresh. Some browsers cache the contents of a web page in order to improve performance. When you go to a web page the first time the browser remembers what text and pictures are in the page. Then, when you go to the page again the browser displays what was previously stored instead of loading it from the server. This works fine for a static web page, but can be problematic for a dynamic simulation in which the same page might display different simulation results each time it is viewed.
Forio Broadcast solves this problem by appending a random number into every simulation URL. If a URL is typed in without the random number, the string "FD_rand=12345" is automatically added to the URL (except that instead of 12345 a random number is used). This ensures that every URL is unique and consequently the browser will never redisplay a cached page.
The key to simulation navigation is to put the following FML statement immediately after your <HEAD> tag on all HTML pages:
|
|
This statement automatically provides special Javascript methods to your web pages. These methods enable #Link and also makes other functionality possible such as decision validation.
Then, instead of a normal hyperlink, use #Link.
|
<A HREF="#Link('result.htm')">Go To Results
Page</A> |
When the HTML file is sent to the browser, it will look like the following:
|
|
This special hyperlink automatically includes a random number and saves the decision form (if one is present).
If you need to use a URL but do not wish to include the JavaScript call, use the macro #LinkURL:
|
|
You might use this in your own JavaScript routine, or if you are creating an HTML meta refresh tag to automatically send the user to a new page.
|
|
When the HTML file is sent to the browser, the HTML source will read:
|
|
If you build your simulation with normal hyperlinks and no #Link, it will often seem to work normally, particularly on non-decision forms. There are two potential problems:
(1) If the page containing the hyperlink has a decision form, when the user clicks the hyperlink all newly entered decisions will be lost.
(2) There will be a slight decrease in performance as the server is forced to regenerate every page to include the URL random number. There may also be some issues with displaying data in frames.
Only URLs used in hyperlinks, refresh meta tags, or JavaScript need one of these macros. URLs used in a form post always cause the browser to load a fresh page and consequently do not need a random number.