This page demonstrates how to detect and handle the case when the server is reporting that a session has expired.
It requires ColdFusion scripting enabled on the server.
The list of cities on the right side of the states is loaded by the 'dsCities' XMLDataSet using a server page that receives the state name as a parameter.
However, this page throws a session expired message after five requests (five clicks on the states), so the "expired" state for that spry:region is going to be displayed.
By default, XMLDataSet looks for "session expired" message in the text response that comes from the server or in the XML-formatted response. If such a message is found, the "expired" state is set for all the spry:regions that depend on the current DataSet.
|
The first 30 cities in the state of "{dsStates::name}":
Loading cities..
Error loading cities..
This sample requires CF support on the server.
Your session has expired!
You need to re-login in order to access the list of cities. Username / password: admin / pass12 |
What is the response required from the server in order for XMLDataSet to detect "session expired" state?
session expired
<?xml version="1.0" encoding="utf-8"?> <reply>session expired</reply>
// the checker receives a request object function MySessionExpiredChecker(req) { if (req.xhRequest.responseText == 'my custom session expired string') return true; return false; } // pass this function to the dataset ds1.setSessionExpiredChecker(MySessionExpiredChecker);