Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CheckActiveFormInSync showing wrong form
#2
I tested your application and I believe that IW is doing the right thing here...

There is no simple answer for that scenario, but IW has several features to allow you to deal with it properly. There is one property in ServerController which is in play here:

- SecurityOptions.PreventDoubleSubmission (default True, set to True in your project)

This is the sequence of events in both cases:

a) 1st case - the one you consider "correct":

- Form1 is active. There is a POST request (let's call it request 1)
- Form2 becomes active.
- F5 is pressed -> The browser sends the POST request (2) again with the same parameters

Because of property PreventDoubleSubmission, IW detects that this is a refresh (request 1 and 2 are identical) and skips the request completely. It basically ignores the request and that's why your browser doesn't change (i.e. apparently on the browser, Form2 is still the active form)

b) 2nd case - the one you consider "incorrect":

- Form1 is active. There is a POST request (let's call it request 1)
- Form2 becomes active
- You press any key inside the memo (here we have another request 2)
- F5 is pressed -> The browser sends the POST request (3) which is exactly the same as request (1). Now, IW won't recognize this as a refresh because request 3 is not the same as previous request 2.
IW also detects that request 3 actually refers to Form1 (because it it the same as request 1) but your active form is Form2. In that case it makes Form1 the active form and processes the request as expected.

IMO, both cases are "correct".

If you disable PreventDoubleSubmission, case (a) and case (b) above should behave the same. But then you loose this feature (which I consider good to keep).

The other way of dealing with it (recommended) is enabling another IW feature which is controlled by ServerController.PostRedirectGet (Default disabled, set to disabled in your project).

You can read about it here: http://docs.atozed.com/docs.dll/classes/...rBase.html

Basically PostRedirectGet will generate a GET request after a POST request. So, when you press F5 the browser won't submit the same POST request again, but the GET request which doesn't do anything other than refreshing the page (without changing the content of the controls).

If you expect your users to press F5 and you have POST requests like that (e.g. IWButton.OnClick events) I strongly recommend you to turn on the PostRedirectGet feature.

There is another "manual" alternative which is using the OnBackButton event (in ServerController). That event will be triggered everytime that a second submit happens (F5 will trigger it). Using it you can manually control what IW does (e.g. SetActiveForm, ExecuteForm, etc).
- SetActiveForm True means that IW will try to set the active form of the application to match the one in the request (it might be different from the one the user sees)
- ExecuteForm True means that IW will go on and process the current active form

Using the PostRedirectGet will avoid all this trouble.

Please let me know if it works for you
Reply


Messages In This Thread
RE: CheckActiveFormInSync showing wrong form - by Alexandre Machado - 05-25-2020, 10:26 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)