Can you catch form has expired exception and reload page?

Discussion in 'Programming' started by bill2012, May 11, 2012.

  1. #1
    I have a cfcalendar wrapped with cfform, every first time start the application, it either is empty or give me form data as expired message.
    I have tried to set cfform timeout to a 100 or 200 seconds, but if you close the application and next time open it (if after the timeout limits) it shows the form data has expired message again. If I don't set or set it to 0, then the next time I open the browser, it give me an empty form page.
    So I wonder if there is a way to catch that exception, and then make it reload the page?

    Please advice!

    
    ...
    <cfoutput>
    <cfheader name="expires" value="#now()#">
    <cfheader name="pragma" value="no-cache">
    <cfheader name="cache-control" value="no-cache, no-store, must-revalidate">
    </cfoutput>
    
    <cfform name="testForm" format="flash" onLoad="#disableRanges#" height="320" width="420"   >
         <cfcalendar name="selectedDate"  
                selecteddate="#Form.selectdate#"
                mask="mmm dd, yyyy" 
                dayNames="SU,MO,TU,WE,TH,FR,SA"
                monthNames="JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC"
                style="rollOverColor:##FF0000;"
                width="270" height="200" 
                onchange="getURL('index.cfm?selectDate=' + (selectedDate.selectedDate.getMonth()+1) + '/' +selectedDate.selectedDate.getDate() + '/' + selectedDate.selectedDate.getFullYear());"
                     > 
    </cfform>    
    
    ...
    
    Code (markup):
    Thanks,
    Bill
     
    bill2012, May 11, 2012 IP
  2. 137th Gebirg

    137th Gebirg Active Member

    Messages:
    70
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #2
    It might be worth trying to figure out why it's giving you that alert in the first place. It almost sounds like the page this form is on is being called through a submit event from a previous page. This is very weird. I've never heard of this happening before.

    The other thing you might want to consider is not using Flash as a display medium for the form (in the "format" tag). Yeah, it might look pretty and easy to build from a rapid-prototyping POV, but you can make nice looking pure HTML forms without it. You should also never assume that your users would have the Flash player installed. I inherited a project from someone who used these Flash widgets everywhere and just was causing weird display issues. Data wasn't being properly transferred to the database and it was VERY difficult to customize the look & feel of the interface. Once I re-tooled it for pure HTML, all the problems went away. Come to think of it, the "form expired" error may actually be a problem with the old CF-generated Flash form object no longer existing in the CF temporary cache directory from a previous page load on the file server. Just for giggles, try it as an HTML form and see if you get that error any more. I bet you won't.
     
    137th Gebirg, May 11, 2012 IP
  3. bill2012

    bill2012 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have tried using HTML format instead. however, the disable range function I customized is not working. HTML enables every dates, I have not found a way to work around so stick to the flash form. I tried to use
    preloader ="true" tag, it works most of the time, but when you reopen a new browser sometime/days later, it happens again. So I am not sure how it can be avoid totally at this point.
    Thanks for your response.




     
    bill2012, May 14, 2012 IP