Complex State & Back ButtonLast Updated: 9/21/2008 | |
| Sections above here: Home » Development » State Management | |
|
Sections below here: Topics in this section: |
Many people quickly discover that when building an IntraWeb application the back button in the browser does not work. By default IntraWeb disables the back button and pressing it has no effect. Please note first that this only applies to application mode. In page mode the back button is fully functional. This limitation is because of the way that IntraWeb allows and uses complex state. Scenario – Normal ApplicationImagine a normal application designed to run on the users local computer. It has five different forms, and for some of the forms multiple instances of that form may be created with different data (such as a properties dialog displaying properties about different objects). Imagine now that at any time, without warning or notice to you the programmer, the user can go to any form in the application. But not only can they go to just any form, they can go to any form, in any prior state, even to versions of the forms which have since been removed from memory. After they move to that form, they can even interact with it. How could such an application deal with this? Here are a few, but certainly not all of the problems:
Back Buttons in non IntraWeb SystemsSystem not built in IntraWeb usually support back buttons. However it is because they fall into one of these categories:
Even applications that support the back button, such problems are still encountered. However because they allow old data to be posted they must check the data to see if the requested operations can be performed. This adds significantly to the amount of user code except in the simplest of systems. Such systems are typically not web applications, but individual dynamic pages. IntraWeb is Not AloneIf you try many online banking applications or ordering systems, many of them have the same restrictions, but do not behave as well. Most of them allow you to go back, but will tell you that you have requested expired content. That is certainly very user unfriendly and confusing to non technical people. Back Button for Historical PurposesUnder limited circumstances the back button can be supported in application mode. It can be enabled for historical purposes. This means that the back button will be enabled, and the user can move backward. However if they try to interact with data on a page that they have reached using the back button they will fail. If the user tries to interact with such a page, a warning will be displayed: You have attempted to post or refresh data from a page that depends on information that is no longer available to the server application. Your attempted changes will be ignored. You will now be resynchronized to the current place in the application. After this warning is shown, the user will be shown the current form as it was before they used the back button. This functionality can be turned on by setting the .HistoryEnabled property to true in the server controller. This warning dialog can also be turned off. To do so set the .ShowResyncWarning property to false in the server controller. If false, instead of seeing the warning dialog the user will simply be resynchronized with the current form. Assigning the OnBackButton eventIntraWeb introduces a new event called OnBackButton. However, despite its name, it does NOT fire when the back button is pressed in the browser. This is due to the nature of the HTTP protocol and therefore the browser cannot send an event to the server to indicate that this has happened. On the other hand, what can be detected is when a form that has already been sent to the server is re-sent. This is where this event comes into play. OnBackButton is fired when a form is re-submitted to the server. The event can therefore be used to detect what operation needs to take place if old data is re-sent. Assigning the event effects two properties: HistoryEnabled and ShowResyncWarning. When an event has been assigned, the first property is automatically set to True whereas the latter is set to False. IntraWeb works in sequences. Each form that is submitted carries a sequence number with it. When the application is first started, the sequence (or track ID) is set to 0. Every time a form is submitted, this track ID is incremented by 1. Sequences play an important role in back button events. The signature for the event is: ASubmittedSequence, ACurrentSequence: Integer; AFormName: String; var VHandled, VExecute: Boolean
For more information and an Delphi example of using the OnBackButton take a look at the BackButton demo located in the application folder. |
(C) 2002-2009 - Atozed Software Ltd. | |