Refresh page

After the user migrates away from the Default Web Page to a distant target page, and then tries to refresh the target page by clicking the browsers refresh (reload) button, the WebApp, instead, always returns the user to the Default page.

I have tried to find an Event in the App or Session where I can trap the activity of the browser’s refresh button, and simply reload the content the user was viewing, but to no avail.

Nearly all of the projects in the Examples folder are single WebPage apps, so I could not find an example to learn from.

What is ‘best practice’ here?

Many thanks in advance

Use the session.hashtag for this.

I can’t get HashTagChanged to occur when returning…?

Demo project

In the open event you can check the hashtag to see what page is wanted or what the hashtag is set to. I didn’t suggest the HashTagChanged event… ?

The documentation for WebSession.SaveState did. Since you offered so little information, I had to look up how to do this and ended there.

i can say you that in all events the hashtag seems to be empty if you moved to another page and go back… i presume that’s a bug since there is a hashtag given in the url?

after returning from google back to the session
Schermafbeelding 2021-03-09 om 16.31.20

Xojo will give you an empty Session.HashTag (or Self.HashTag) so i guess xojo has no such feature, call it a bug but it’s probably again by design…

It will even do so if i refresh the page again.

Even 5/10 times no events are raised when returning to the webpage oddly.

:man_shrugging:

I was just attempting to understand how to do this from the documentation. Seemed like it wasn’t straight forward or wasn’t working. I gave up there, I can only spend so much time on debugging Xojo Web basics.

2 Likes

HashTagChanged fires correctly when the Hashtag changes, but not on page load (maybe because it’s not so much changing as that’s it’s first state?).

I have an implementation where I do perform operations based on the hashtag, and I use Session.Open to check the HashTag property of the Session instance when setting up to forward to the correct page:

Sub Opening() Handles Opening
  if me.HashTag.Length > 0 then
    select case me.HashTag
    case "billing"
      System.DebugLog( "Loading Billing portal" )
      ...
    case "support"
      System.DebugLog( "Loading Support portal" )
      ...
    end select
  end if
End Sub

Any other time that HashTagChanged fires, it will also navigate to a new matching page.

Sub HashTagChanged(Name as String, Data as String) Handles HashTagChanged
  select case Name
  case "billing"
    System.DebugLog( "Loading Billing portal" )
    ...
  case "support"
    System.DebugLog( "Loading Support portal" )
    ...
  end select
End Sub
2 Likes

My tests didnt paste my “#” into the url, but even with the “#” the event’s wont raise using “#hello” the hashtag is always removed from the url when the page is returned back.

I see what you’re saying. When navigating back in the browser, after going to another page, the hashtag is removed. From reading on SO, this may be an issue with Modernizr and should be filed in Feedback.

1 Like

What you are talking about is Session restoration, this was announced as a Web 2.0 feature, BUT it was not implemented.

So, almost 2 years after the las web 1.0 release, web 2.0 is still feature incomplete:

All that HashTag changes and WebSession.SaveState could be used as a work around if you implement manually a system to save all the controls states, page variables, etc to restore them manually when the page refreshes (xojo opens first page, you read the states, load the las visited page and restore all the values to the page)

Tell users not to refresh the page :sweat_smile:

While I agree it feels like longer, the last release of Web 1.0 (2019r3.2) was only eight months ago and Web 2.0 only 6½ months.

Ivan:
Unfortunately, the user is me…as I repeatedly test functionality of controls etc. by hitting the Refresh button. That is the frustration…each time I end up back at the Default Web Page and have to drill back down to where I was working…

The Apple HIGs warn against programming strategies that force a ‘context switch’ on the user without their expectation…and now I see what that recommendatation is based on.

Seems to me that the framework should offer a ‘Reload Page’ event in the Session, where we can also destruct and reinstantiate what the page needs…but just my humble suggestion…

1 Like

With this use case, you could probably set a cookie to send you back to the right page from Session.Opening

3 Likes

You could also give WebSession.RecordData and WebSession.RequestData a shot. I believe this saves data to the in-browser database the same way I do for GraffitiStorage.

2 Likes